Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It would seem like less of a kludge if DOES> precipitated into a deferred context terminated by its own semicolon. So you could just type

  CREATE FOO 42 , DOES> @ ;
into an interpreter to create the constant. Then if placed inside a definition, there would be two semicolons:

  : CONSTANT CREATE , DOES> @ ; ;
It's an extra nesting which makes it clear you have a definition that makes a definition. You could even put words between the semicolons which just become part of the definition of CONSTANT.

It feels as if this DOES> thing is a kludge that activates within definitions, and kind of "hijacks" the rest of their instructions. Without DOES>, the material after it would be part of the definition of CONSTANT and not part of the definition of the word produced by CREATE. The switcheroo feels hacky.



DOES> is separate from the definition. The compiler just remembers what the most recently defined word was, and DOES> modifies a cell in that word's dictionary entry.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: