Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In the Io language, how can you see the implementation of "if"?

I was poking around some of Core and Object using "getSlot("method name") to see how some foundational methods were implemented. I was curious about how the if method was written and tried

Io> Object getSlot("if")
==> Object_if()
Io> Object getSlot("Object_if()")
==> nil

Neither of these were informative. Is there a way to reflect/inspect/print this (and other Object_keywordishword() words)?

like image 530
labyrinth Avatar asked Dec 01 '25 05:12

labyrinth


1 Answers

I gave a talk to a group in New York a while back which included a cleanroom implementation of if if you're curious about the mechanics. You can see it here.

More directly, when you see:

==> Object_if()

In the REPL, what that's telling you is that if is a symbol bound to the object Object which is implemented in C. That is to say, the "method" is actually a CFunction object, and not a Block object. Only Block objects show their source in the REPL.

like image 113
jer Avatar answered Dec 04 '25 21:12

jer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!