[nem-en] default parameter value

Kamil Skalski kamil.skalski at gmail.com
Sat Mar 10 20:36:07 CET 2007


Hm... wait a moment - I can see following code in parser:

          mods.custom_attrs = <[
System.ComponentModel.DefaultValueAttribute ($e)
                              ]> :: mods.custom_attrs;

So maybe come back to the original question and try
System.ComponentModel.DefaultValueAttribute attribute... :)

And here I can see there is a collision of having ..$attrs   and   =
$default at the same time.

2007/3/10, Ivan A Eryshov <ivan.eryshov at gmail.com>:
> How should I define a parameter with a default value from macro? Such code
> not compiles:
> <nemerle>
>   <[ parameter:
>     ..$attrs $(n : name) : $(mem.GetMemType() : typed) = $default
>   ]>
> </nemerle>
>
> > -----Original Message-----
> > From: devel-en-bounces at nemerle.org [mailto:devel-en-bounces at nemerle.org]
> > On Behalf Of Kamil Skalski
> > Sent: Saturday, March 10, 2007 8:37 PM
> > To: devel-en at nemerle.org
> > Subject: Re: [nem-en] default parameter value
> >
> > Such attributes are interpreted only when loading external libraries.
> > For compile-time code compiler uses its own information basing on
> > presence of
> >
> > foo (x = bar) { }
> >
> > construct
> >
> > 2007/3/10, Ivan A Eryshov <ivan.eryshov at gmail.com>:
> > >
> > >
> > >
> > >
> > > Why this code not compiles?
> > >
> > > <nemerle>
> > >
> > > module A
> > >
> > > {
> > >
> > >   Test([Optional, DefaultParameterValue(10)] p : int) : void
> > >
> > >   {
> > >
> > >     System.Console.WriteLine(p);
> > >
> > >   }
> > >
> > >   Main () : void
> > >
> > >   {
> > >
> > >     Test(); // wrong number of parameters in call, needed 1, got 0
> > >
> > >   }
> > >
> > > }
> > >
> > > </nemerle>
> > >
> > >
> > > _______________________________________________
> > > https://nemerle.org/mailman/listinfo/devel-en
> > >
> > >
> >
> >
> > --
> > Kamil Skalski
> > http://nazgul.omega.pl
> >
> > _______________________________________________
> > https://nemerle.org/mailman/listinfo/devel-en
>
>
> _______________________________________________
> https://nemerle.org/mailman/listinfo/devel-en
>


-- 
Kamil Skalski
http://nazgul.omega.pl



More information about the devel-en mailing list