Skip to content
vidarh edited this page Sep 13, 2010 · 1 revision

One of the challenges of combining Ruby with the embedded low level s-expression syntax is handling literal strings. For calling C functions etc. it’s necessary to support access to the raw character data. For calling Ruby code it needs to be a proper string object.

There’s a couple of alternative ways of handling that:

1. Treat literal strings in s-expression blocks as raw data, but treat literal strings everywhere else as String.new_from_literal_data(“string”).
2. Change the object model so that the class pointer is at -4, and let literal strings have the string data start at offset 0. This works but doesn’t allow expanding strings without re-allocating them.
3. Automatically call an internal String.
to_literal_data type method when doing a (call …). Problem is this would have to be done for all objects, and so we’d need to deal with fixnums etc. too.

I’m leaning towards option 1. combined with implementing “native” Ruby versions of puts / print and updating example code to use it. Impact of changing string might be fairly high.

Clone this wiki locally