proporty syntax dosn't work for static memebers (under some cases)
BCS
ao at pathlink.com
Thu May 17 13:23:13 PDT 2007
Reply to Frits,
> BCS wrote:
>
>> struct S
>> {
>> static void F(ref S* s){}
>> }
>> void main()
>> {
>> S* s;
>> s.F(); // fails
>
> Of course it fails. You forgot to specify an argument.
Ok, I didn't /forget/, I was trying to use the array property syntax on a
struct pointer. As you point out, it doesn't work in any case (their be my
error).
> I'm not sure what you're trying to do here and what it has to do with
> property syntax.
> However, you seem to think that calling a static method from an
> instance
> (or pointer) should pass what it's called on as a parameter? The only
> thing that works anything like that is arrays and functions that take
> them as the first parameter...
I would consider the fact that this /only/ works with arrays a bug or missed
feature.
this works:
struct S {}
void F(S[] s){}
void main()
{
S[] s;
s.F();
}
so why shouldn't this
struct S {}
void F(S s){}
void main()
{
S s;
s.F();
}
then the logical next step is what I was trying.
> (Also, please note that what's more commonly referred to as "property
> syntax" in relation to D is leaving off the parameter brackets from a
> no-argument function or "assigning" something to a single-parameter
> function)
Semantically there is little difference between the two, both allow a function
to be used with some of the parameter list defined differently. It's not
exactly the same, but I think the connection should be easy to see.
More information about the Digitalmars-d-bugs
mailing list