Newsgroups: perl.perl6.language
From: la...@wall.org (Larry Wall)
Date: Sat, 2 Aug 2003 13:07:55 -0700
Local: Sat, Aug 2 2003 4:07 pm
Subject: Re: Macro arguments themselves
On Sat, Aug 02, 2003 at 01:18:01PM -0600, Luke Palmer wrote: : While we seem to be on the subject of hashing out macro semantics, : here's a question I've had awhile. : : What do macros do about being passed variables? : : Let's say I make a C<square> macro: : : macro square ($x) { : { $x * $x } : } : : And then I have code. : : my $var = 10; : print square $var; : : Does that turn that into (at compile time): : : print($var * $var); : : Or does it use the compile time value of $x, turning it into: : : print(undef * undef); : : I would hope the former. It's the former. The block is essentially inlined. : However, what about this compile-time Nope. $x and $p are syntax trees. If you want compile-time evaluation macro power ($x, $p) { That might be reducable to: macro power ($x, $p is run) { But you can't decrement $p inside the block, or it just becomes part of : But what about Depends on how power is written. Can't have it both ways unless power is : [1] That one's kind of interesting actually. If the macro is called I suppose one could defer the expansion of a nested macro till it's macro power ($x, $p is run) { Alternately, we just defer the expansion of any declared but undefined Those are both hard. Unless someone volunteers to implement it, Larry You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||