Grokbase
Topics Posts Groups | in
x
[ help ]

Re: syntax for macros / function composition at compile time

View PostFlat  Thread  Threaded | < Prev - Next >
Matt S Trout Re: syntax for macros / function composition at compile time
| +1 vote
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
On Thu, Nov 06, 2008 at 04:59:41AM -0800, Michael G Schwern wrote:
> I still say subroutine attributes are the way. That's the syntax for
> attaching things to a subroutine in Perl 5. I'd make a decorate() attribute
> and pass it the decorators.

That's not what attributes do though, they call a class method at a random
point when the sub doesn't have a name yet and then you do a crazy dance to
try and do something useful with them.

We hates attributes, we do.

> sub incr : decorate(memoize, log($file)) {
>     $_[0] + 1;
> }

Meh. How about

memoized logged (to => $file) sub incr (Int $i) {
  $i + 1;
}

?

We can certainly decorate 'method' like that. Not sure if it's possible
with sub; when rafl took over trying to make sub signatures work I kind of
forgot most of what little I'd worked out about how 'sub' is parsed in
statement form.

Better still, how about we shift off to the perl5-syntax list and stop
bothering p5p until we have something worth shoving into core? :)

--
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
Technical Director http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.vox.com/ http://www.shadowcat.co.uk/servers/

Thread : syntax for macros / function composition at compile time
1)
Erwan Lemonnier Hi list! I need some enlightened help with a matter of language syntax design. I have been toying...
2)
Michael G Schwern There's also been a lot of work lately in taking over subroutine declarations without a source...
3)
Erwan Lemonnier Hi Michael! Thanks for your answer! I have followed a bit the ongoing with sub signatures in perl5....
4)
Michael G Schwern I still say subroutine attributes are the way. That's the syntax for attaching things to a...
5)
Erwan Lemonnier Ok! Now I understand what you meant :) I agree that it would be a smooth and more perlish way to...
6)
Florian Ragwitz I think I'd prefer adding a 'decorate' keyword using Devel::Declare. decorate foo with cache,...
7)
Tux Not that I would use it, but both syntaxes will make my eyes hurt in sytax highlighting editors and...
8)
Erwan Lemonnier That's a very good point! Indeed. This one from Florian is my personal favorite so far :) One thing...
9)
Matt S Trout That's not what attributes do though, they call a class method at a random point when the sub...
10)
Matt S Trout Yes there is. It's irc.perl.org#devel-declare since that's where rafl and I collaborate on the...
11)
David Nicol Due to "late binding," I don't think you need any new syntax for this, just as MJD's memoize...
12)
Erwan Lemonnier Hi list! I need some enlightened help with a matter of language syntax design. I have been toying...
13)
A. Pagaltzis Uhm, you know about subroutine attributes? See perlsub and Attribute::Handlers. Regards,
spacer
View PostFlat  Thread  Threaded | < Prev - Next >