I don't think this is a bug but...
Jeremie Pelletier
jeremiep at gmail.com
Fri Aug 14 16:15:38 PDT 2009
BCS Wrote:
> Reply to Jesse,
>
> > Benjamin Shropshire Wrote:
> >
> >> The same expression twice gets different results
> >>
> >> code:
> >>
> >> import std.stdio;
> >>
> >> bool Fn(float i){ return true; }
> >> const bool b = Fn(cast(int)0);
> >> static if(b) bool Fn(int i){ return false; }
> >> const bool c = Fn(cast(int)0);
> >> void main()
> >> {
> >> writef("%s\n", b);
> >> writef("%s\n", c);
> >> }
> >> output:
> >>
> >> true
> >> false
> > The value of 'b' is assigned during compile time, but since it is
> > indirectly called the behavior seems odd. I suppose it is something to
> > be aware of, but it is behaving correctly.
> >
>
> The only other option (beside saying this is correct) would be to make it
> illegal to add a new function to an overload set after the set is used. That
> could get very tricky to implement.
>
>
I don't think this is a good idea, since overload sets can be hijacked there is nothing that prevents a module from using a local overload set, and another then using it alongside its local hijacks.
Having such a "feature" would only limit the programmer in what they can do.
More information about the Digitalmars-d
mailing list