From: "David Nicol" <[EMAIL PROTECTED]>
> On Dec 1, 2007 2:22 PM, Joshua ben Jore <[EMAIL PROTECTED]> wrote:
> > On Dec 1, 2007 8:51 AM, Jenda Krynicky <[EMAIL PROTECTED]> wrote:
> > > From:                   "David Nicol" <[EMAIL PROTECTED]>
> > > > On Nov 30, 2007 7:24 PM, Jenda Krynicky <[EMAIL PROTECTED]> wrote:
> > > > > I'm missing the reason-for-being of the module it its docs. I read
> > > > > the whole documentation and the test script and I still don't get it.
> > > > >
> > > > > What is it supposed to be used for?
> > > > >
> > > > > Sorry, Jenda
> > > >
> > > >  polymorphic functions / more complex prototypes
> > >
> > > Any examples?
> 
> Currently when you want to have a sub act differently depending on
> how many arguments are supplied to it, rather than the naive
> 
>    sub  poly($) { print "got one arg, @_\n" }
>    sub  poly($$) { print "got two args, @_\n" }
> 
> working as intended, you have to do something like
> 
>    sub  poly($;$) {
>           @_ == 1 and return print "got one arg, @_\n";
>           print "got two args, @_\n"
>    }

If you do that I assure you you'll hear very soon that you should not 
use prototypes. They are great if you need to make sure some 
userdefined function has the same interface as a builtin or if you 
are trying to add a new syntax (try{} catch {} or something), but 
should not be used if all you want is to have a function that takes 
one or two parameters.

What does 

  sub  poly($;$) {
    @_ == 1 and return print "got one arg, @_\n";
    print "got two args, @_\n"
  }

  @a = (10, 20);
  poly(@a);

do? I hope you do know and do expect the result.
 
> Using Macrame, you can do
> 
>    sub  _poly1arg($) { print "got one arg, @_\n" }
>    sub  _poly2arg($$) { print "got two args, @_\n" }
>    macro poly(one,two) { _poly2arg(one,two) }
>    macro poly(one) { _poly1arg(one) }
>    macro poly one,two { _poly2arg(one,two) }
>    macro poly one { _poly1arg(one) }

Which seems to me much more wordy and harder to understand.

> A feature I believe can be added using 0.08 syntax is the idea of having
> "my" create a reference
> 
>      macro my \$alias = \$Item; {
>         my $alias;
>         $alias = \$item;
>         macro alias { {NOMACROS $alias} } # from here on, $alias is
> "really" ${$alias}
>     }
> 
> which may sort of work at this point.

erm ... I wanted to see the use, not the implementation of something 
made possible with Macrame. Or is that it?

If you want to create an alias to something you have a reference to 
you can do it using for(){} or Data::Alias, Lexical::Alias or 
Devel::LexAlias.
 
> > > Looking at the KNOWN BUGS it doesn't look like this works too well.
> > > Any examples of a "new syntax" that you would like to be able to
> > > create? So that we can see how close would we be able to get without
> > > using source filters.
> 
> Macrame _is_ a source filter; it provides a filtering syntax that abstracts 
> away
> some parsing steps.

Yes, I know it is a source filter. And has all the problems of source 
filters ... that is it can misunderstand something, transform your 
source code in completely unexpected way and cause next to impossible 
to find bugs. As such it needs to do something really really 
important to warrant the danger.

I do not want to ruin the fun, maybe something great will evolve from 
this, but so far you did not convince me. If you are treating this as 
an experiment, great, just don't be disappointed if it doesn't work 
out. I think it wount.

Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery

Reply via email to