« Return to Thread: Under the hood.

Re: Under the hood.

by tobeythorn :: Rate this Message:

Reply to Author | View in Thread

--- In iolanguage@..., Steve Dekorte <steve@...> wrote:

>
>
> On 2009-06-04, at 7:31 AM, tobeythorn wrote:
>
> > I've been trying to understand how Io works and what goes on under  
> > the hood. I'm becoming more and more impressed with it, but am a  
> > little confused about a a few things.
> >
> > What are the statements 123 and "this is a word" and TRUE, FALSE,  
> > and NIL? Are they messages, or objects, or messages routed to a  
> > special built in hidden object that constructs these objects?
>
> Hi Tobey,
>
> Everything compiles to a tree composed of messages. Literals such as  
> numbers and strings in the source become instances of number and  
> string objects attached to a Message object's "cachedResult", which  
> short circuits the message send and just returns the cachedResult when  
> that message is evaled.
>
> true, false, and nil are just objects found in slots in the Lobby  
> Protos Core. IIRC, we don't put those in cachedResult, but it would  
> probably speed up the code (but slightly alter the semantics) if we did.
>
> Cheers,
> - Steve
>

Steve,
Thanks for your previous reply.
I know it has been a while since I first started this thread, but I have a related inquiry. In the following Io code.

55 myMethod := method("hello" print)
55 myMethod

the output is "hello", which I find quite remarkable, since there are nearly infinite number of numbers and it doesn't seem that 55 is made a slot of lobby by the first line. It isn't obvious to me how 55 and its slot myMethod are remembered.

Furthermore, the 55 doesn't appear to have any protos or slots, while Number does have slots but no protos. Somehow though, 55 can still be printed, or can have arithmetic operators called on it, as if it has Number as a prototype.

The same peculiarities apply to strings as well.

Again,
Thanks for you insight!





 « Return to Thread: Under the hood.