J
Jamis Buck
I've been poking around the Ruby internals, trying to understand the
black magic that makes the whole thing run.
I think I finally
understand the garbage collection stuff (and how it determines the roots
from the stack and registers), but I have a question now about some of
the macros I've seen: why do some macros wrap their contents in a "do {
... } while(0)"? Is this preferable to simply wrapping them in curly
braces ("{...}")? Is it simply a matter of matz's programming style, or
is there some subtler issue in effect here?
A few macros that do this (for curious persons to reference) are
JUMP_TAG (in eval.c) and RUBY_CRITICAL (in rubysig.h), though there are
several others.
Thanks! (And if there is a more appropriate list for posting questions
regarding the implementation of Ruby, please direct me there. Thanks
again!)
black magic that makes the whole thing run.
understand the garbage collection stuff (and how it determines the roots
from the stack and registers), but I have a question now about some of
the macros I've seen: why do some macros wrap their contents in a "do {
... } while(0)"? Is this preferable to simply wrapping them in curly
braces ("{...}")? Is it simply a matter of matz's programming style, or
is there some subtler issue in effect here?
A few macros that do this (for curious persons to reference) are
JUMP_TAG (in eval.c) and RUBY_CRITICAL (in rubysig.h), though there are
several others.
Thanks! (And if there is a more appropriate list for posting questions
regarding the implementation of Ruby, please direct me there. Thanks
again!)