[nem-en] default parameter value
Ivan A Eryshov
ivan.eryshov at gmail.com
Sun Mar 11 08:21:19 CET 2007
Yeah, it works now. But, very strange of seeing here the
DefaultValueAttribute. It was designed to provide default values for
properties, but not parameters.
> -----Original Message-----
> From: devel-en-bounces at nemerle.org [mailto:devel-en-bounces at nemerle.org]
> On Behalf Of Kamil Skalski
> Sent: Sunday, March 11, 2007 1:36 AM
> To: devel-en at nemerle.org
> Subject: Re: [nem-en] default parameter value
>
> 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
>
> _______________________________________________
> https://nemerle.org/mailman/listinfo/devel-en
More information about the devel-en
mailing list