develooper Front page | perl.perl5.porters | Postings from November 2017

Re: square signatures

Thread Previous | Thread Next
From:
David Nicol
Date:
November 21, 2017 17:54
Subject:
Re: square signatures
Message ID:
CAFwScO_YK1V-=F55SfApiqH4gez9ujabn=5+9_cf4sgm-uM0fQ@mail.gmail.com
Yes, we've already got cpp macros, although nobody ever uses them that I've
ever seen.

Can you construct a cpp marco that would provide a sigsub shortcut? I don't
think its possible without unbalancing the curlies, because cpp macros
can't define circumfix syntaces, only prefix.

#define SIGSUB(name,varz...) sub name { my ( varz ) = @_ ;
#define ENDSUB }
...
SIGSUB(dofoo, $self, $foo, $bar, $baz, $waldo)
     $self->$foo($bar,$waldo) if $baz;
     ...
ENDSUB
...
$obj->dofoo($current_foo, $foo_arg1, $foo_arg2, $certinator)

__END__

Hey! My code formatter forced everything left!



On Tue, Nov 21, 2017 at 10:39 AM, David Cantrell <david@cantrell.org.uk>
wrote:

> On Mon, Nov 20, 2017 at 11:33:03AM -0600, David Nicol wrote:
>
> > My unusual opinion on this matter continues to be that instead of
> providing
> > a signatures syntax, it would be better to provide a macro syntax that is
> > capable of defining a signature syntax.
> >
> > #<<< no tidy
> >     MACRO sigsub [ M@1 ] { EXPANDS TO 'sub {  my (M@1) = @_;'; # no
> need to
> > quote whatever is betwen MACRO and EXPANDS TO because MACRO seized the
> > input stream and M@n means
> > #>>> resume balancing curlies
>
> How about we spell the switch for turning on macro juiciness '-P'.
>
> --
> David Cantrell | top google result for "internet beard fetish club"
>
>   For every vengeance, there is an equal and opposite revengeance.
>                                             -- Cartoon Law XI
>



-- 
Hi-jinks ensue.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About