tag:blogger.com,1999:blog-27488238.post5064734666391503612..comments2024-03-22T11:34:45.165+01:00Comments on taw's blog: Regular expression matching in RLisptawhttp://www.blogger.com/profile/16972845140253292628noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-27488238.post-90723574661115619332007-05-30T16:10:00.000+02:002007-05-30T16:10:00.000+02:00Fabien: If you need to create new scope in RLisp y...Fabien: If you need to create new scope in RLisp you can do ((fn() code)), there's even standard macro for that - (local code).<BR/><BR/>Paul Graham did something else - every (do ...) created a new scope, and many macros accidentally created new scopes by using (do ...) when they didn't mean to. I don't think any macro will accidentally do ((fn() ...)).<BR/><BR/>So far it never bit me, and it helped me in most of the macros I wrote. If it ever does, I will certainly post about it.tawhttps://www.blogger.com/profile/16972845140253292628noreply@blogger.comtag:blogger.com,1999:blog-27488238.post-65590264136976202822007-05-30T11:40:00.000+02:002007-05-30T11:40:00.000+02:00About (let ...) extending the current scope instea...About (let ...) extending the current scope instead of creating its own: I agree that it makes human-written code easier to read, by avoiding code nestings which don't correspond to the programmer's mental image. I also acknowledge that in some cases, it makes some macros easier to write. However, my experience is that it bits you more often than it helps when writing metastuff (metalua has essentially the same structure, inherited from Lua, which extends the conatining block's scope: `Local{ vars_list, values_list }).<BR/><BR/>As soon as a macro needs a tight control of scope, variable shadowing etc. I need to handle code blocks in custom ways in order to parse local declarations correctly. That's especially the case with code walkers: alpha renaming, runtime type-checking insertion...<BR/><BR/>IIRC, Paul Graham came to the same sort of conclusion in his design of Arc: he initially thought that inserting local variables in their containing scope was nicer, but found it to be a nightmare for macro writing and backed down. I'll try to find his quote.<BR/><BR/>Finally, your statement that "it makes macros much easier to write" should be slightly narrowed: having an "extend containing scope" semantics made it easy for you to write a regexp parser which also respects "extend containing scope" semantics. Schemers would naturally have written a macro which creates its own scope, so they would have completely avoided the problem you solved.Fabienhttps://www.blogger.com/profile/02739446213556869485noreply@blogger.com