Macros and modules and certificates, oh my!

I've spent the last couple weeks trying to what should have been a simple task, and I feel the need to publicly whine and complain about how hard it has turned out to be.

All I want is to fully expand a mzscheme module definition and then do some syntactic rewriting on it. I expected to be able to write something like this:

(define optimize (λ (code) (rewrite (expand code)))

Oh, how naive I was...

I have learned about the difference between expand, expand-syntax, and local-expand. I have learned that local-expand requires its caller to specify whether it's in an expression context, module context, toplevel context, or some weird list context whose purpose I have yet to understand.

I have learned about the all-important datum->syntax-object function, which is the only way to make mzscheme realize that when a function appears in function-call position, it is meant to be called.

I have learned that telling local-expand that it's in a module context does not mean that you can expand code that actually came from a module context, because the "module" macro has special handling for define-values.

I have learned about the difference between module-identifier=?, bound-identifier=?, and free-identifier=?.

I have learned that a define-for-syntax binding cannot be exported from a module. You must either suck callers into the same module, or find some way to rewrite it as a regular define.

I have read about require-for-template half a dozen times, and I still don't understand its purpose. I have learned about namespaces, but I haven't yet seen the need to use them.

I have learned that macros can be expanded on demand, by using syntax-local-value to retrieve their syntax transformer. I currently count this discovery as a minor victory. I have learned that for some reason this does not insert #%app, #%top, or #%datum wrappers. I do not know where these wrappers usually come from.

I have learned that if you attempt to rewrite an expanded expression, then you will be sent to certificate hell. I am currently reading about certificates. In order to understand them I must learn about "marks" and "inspectors". I must decipher obscure writings, such as:

To check access to an unexported identifier, the compiler or macro expander checks each of the identifier's marks and module bindings; if, for some mark, the identifier's enclosing expressions include a certificate with the mark, the identifier's binding module, and with an inspector that controls the module's invocation (as opposed to the module's declaration; see again section 9.4), then the access is allowed.

And it is about at this point that I realize how far I have come, and I begin to question why the journey was required in the first place.

Never let it be said that the mzscheme macro & module system is simple.

Posted on July 22, 2006 03:14 PM
More languages articles

Comments

Thanks for a beautiful site! I have added you in elected!
Necessarily I shall advise your site to the friends!
http://shsrth.hostxd.com
http://fgfhat.byteact.com
http://fgfhat.byteact.com
http://xgfnxg.4qh.info
http://vbxhg.fastsit.com
http://xfghgf.fasthoster.info
http://fgfhat.byteact.com
http://sexy.freeinternethosting.info

Posted by: Bob at June 13, 2008 02:45 PM

There is nothing that touches these for just lazing around at home. Bar sleeping I don’t take mine off now that its getting colder, they are not quite as stiff as they were when they first arrived but still extremely comfortable. It would be nice if they had a little more arch support but other than that I’m very pleased. I am finding a nice ugg boots!

Posted by: ugg boots at November 5, 2009 02:43 AM

Just wanted to say great job with the blog, today is my first visit here and I’ve enjoyed reading your posts so far

Mukluk boots

Posted by: Mukluk boots at November 5, 2009 02:44 AM

Everything dynamic and very positively!

NIKE

Posted by: NIKE at November 5, 2009 02:48 AM

Good work, thanks! My sister received the Mbt Health shoes I bought her for her birthday, she adores them. I was a little worried the calf would be tight around her legs but it hasn’t been a problem. I’ll be back before Christmas.


Posted by: Mbt Health shoes at November 5, 2009 02:48 AM

I think I will try to recommend this post to my friends and family, cuz it’s really helpful.

Thanks for this nice post, i like it very much, write this article more.Nike Air Max 2003 Shoes
.

Posted by: Nike Air Max 2003 Shoes at November 5, 2009 02:49 AM

Only One word to characterize such a great post “WOW” that was a very interesting read
Adidas

Posted by: Adidas at November 5, 2009 02:49 AM

Find Jeans ?!UGG boots On Sale ,Enjoy free shipping + bargain sale now!

UGG Classic Short,100% Authentic UGG Australia Boots!ALL of

Jeans are the cheapest and best for you!Enjoy yourself of shoping , Find Cheap Sheepskin
Jeans !



Posted by: Jeans at November 5, 2009 02:51 AM

We also supply other products such as:

Mukluk boots


Shoes


NIKE


Jeans


Handbags


Lacoste Shoes


Jeans


Watches


Handbag


Adidas


DVD .Welcome to order it.

Posted by: surprise at November 5, 2009 02:51 AM

Hey, i am very happy today, I received my Mbt shoes

just now, very impressed. They are like sort of a massive slipper, soft, easy to wear and

light.

Posted by: Mbt shoes at November 5, 2009 02:51 AM

There is nothing that touches these for just lazing around at home. Bar sleeping I don’

t take mine off now that its getting colder, they are not quite as stiff as they were when

they first arrived but still extremely comfortable. It would be nice if they had a little

more arch support but other than that I’m very pleased. I am finding a nice
mbt shoes sale!

Posted by: Mbt shoes at November 5, 2009 02:52 AM

Louis Vuitton, commonly referred to as Louis Vuitton Bags and Louis Vuitton Shoes, or sometimes shortened to Louis Vuitton Speedy 30 has become one of the most Louis Vuitton Tivoli PM Agendas luxurybrands Louis Vuitton Tivoli PM.

Posted by: 1 at November 17, 2009 01:54 AM

UGG Bailey Button bootsis a new style in 2009.The classic cardy uggs boots is another hot boots that worth of buying.And the classic tall ugg boots will make your winter amusing.And now uggs on sale,if you are looking for such a boot,the ugg boots is good choice this year.

Posted by: uggs on sale at November 17, 2009 08:31 PM

Uggs on sale now.Classic cardy boots ugg is a special boot that makes you different from the other girls.And the Bailey Button UGGs is hot in 2009.If you want to get a warm shoe in cold winter,I think ugg classic tall boots is a good choice for you.

Posted by: ugg classic cardy boots at November 17, 2009 08:59 PM

www.enjoywholesale.com

china wholesale clothing,china wholesale shoes,china wholesale electronics,china wholesale suppliers,china manufacturers

china wholesale products,light in the box,wholesale lots,wholesale ipod
china direct,china dropship,china trade,made in china

electronics wholesaler,ebay wholesaler,financial wholesaler
fashion wholesaler,clothing wholesaler,wholesaler magazine

computer wholesaler,external wholesaler,dvd wholesaler,wholesaler definition,china wholesaler,mutual fund wholesaler,define wholesaler,insurance wholesaler


discount ugg boots
forture
ugg boots
Discount store

Posted by: wholesaler business website, net shopping site, external wholesaler,dvd wholesaler,wholesaler definition,china wholesaler,mutual fund wholesaler,define wholesaler,insurance wholesaler at November 18, 2009 02:52 AM

We are the best online sales for the china wholesale . Here you can have a large of choices of kinds Ugg Boots,Converse Shoes,Timberland Boots,puma shoes,Nike Shox Shoes ,Nike Dunk SB Shoes,Nike Air Max,Links Of London,Tiffany Jewelry,Dior Handbags?,jimmy choo handbags ,Cartier Watches, 8GB Mp4 Players,Bluetooth Car DVDs. All our cheap online cheap goods are high quality and original packages, and best service. We offer our customers the best service, 7 days arrive at your door.Enjoy your easy and happy shopping with us.

Posted by: cheap goods sale. at November 20, 2009 01:55 AM

Good day! Thx for your great post and Im thinking about how to introduce my ugg boots to you cos Im not sure if u like this. Many people who live in the cold area like the ugg boots, especially the north-europe. Our uggshare.co.uk supply the cheapest classic cardy ugg boots, class tall ugg boots, classic short ugg boots and other series of uggs, hope my words didn’t trouble u, cy!

Posted by: ugg boots at November 23, 2009 09:00 PM

People all over the world know the abercrombie and fitch,but not everyone really knows how fashion the abercrombie is,hollister is the Legend maker. Everybody wears the hollister clothing would be the abercrombie mens and the abercrombie womens, if you want know you can search the Ruehl No.925 or abercrombie outlet in the www.google.com .

Posted by: fitch at November 24, 2009 09:23 PM

Laptop Battery Laptop Battery Laptop Batteries
Laptop Batteries discount laptop battery
discount laptop battery
notebook battery notebook battery
computer battery computer battery
replacement laptop battery replacement laptop battery
notebook batteries notebook batteries

Posted by: Laptop Battery at November 24, 2009 10:36 PM

Ugg Classic Cardy

Boots

Ugg Classic Tall

Boots

Ugg Classic Short

Boots

Posted by: topuggshoes at November 26, 2009 02:34 AM

Just wanted to say great job with the blog, today is my first visit here and I’ve enjoyed reading your posts so far
ugg bailey button
Wow, my ugg classic mini will not be coming off now! I’ve had them on for 12hrs strait and I do not want to take them off. Thanks for everything, well worth the wait.

Posted by: ugg bailey button boots at November 30, 2009 05:50 AM
Post a comment









Remember info?




Prove you're human. Type "human":