Hacker News new | ask | show | jobs
by runewell 4186 days ago
I really love this. Are there convenience functions to convert existing values to and from your new data types?

I would love to use this library but as C programs often requires third-party libraries I could see many instances of having to use normal C types. Is there a way, for example, to easily convert a float to and from a var (with a Real key/value)? How would I use your library to take hash table values and assign them back into standard struct members? Would I just use traditional casting? Something tells me normal casting is not an option, or at least not so easy.

1 comments

Converting a C value to a Cello value is easy.

  int cValue = 5;  // because I randomly feel like that's a good number
  var celloValue = $(Int, cValue);  // I'm pretty sure this works, but I haven't proven it
Coming back from Cello to C, it appears that you can do this:

  long anotherCValue = as_long(celloValue);