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

    only if you don't look too closely
Look as closely as you'd like. :)

    what about break and continue?  They are usually
    supported by native foreach construct but are
    difficult to build with macros..
For break, DOLIST uses return. I haven't worked with Lisp in some time, so I don't remember if it has a dedicated continue. But a continue is just a break in a loop that doesn't loop. Or a GOTO by another name. Or a jump to a particular case in a switch.

But if your looping macro uses a native looping construct or another macro that supports break and continue, then your looping macro will inherit that support, provided that you're careful when writing the macro to do nothing that will break it.

If your looping macro doesn't use a construct that supports break and continue, then you're still in luck. Continue I described above. Like continue, break is also GOTO by another name. You've got TAGBODY, GO, CALL/CC, etc.

Why do you think that supporting break and continue in macros is difficult?



> Why do you think that supporting break and continue in macros is difficult?

In many languages, emulation of control loop do not support break and continue so I thought that this was the case also here, but apparently I'm wrong, sorry for my 'too quick' post and thanks for the correction.




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

Search: