Thread overview
Re: Prevention of UFCS hijacking
Aug 27, 2013
H. S. Teoh
Aug 27, 2013
Andrej Mitrovic
Aug 27, 2013
H. S. Teoh
Aug 27, 2013
Maxim Fomin
Aug 27, 2013
Andrej Mitrovic
Aug 27, 2013
Jesse Phillips
Aug 27, 2013
H. S. Teoh
August 27, 2013
On Tue, Aug 27, 2013 at 08:02:18PM +0200, Andrej Mitrovic wrote: [...]
> Btw, why exactly is the following allowed to compile?:
> 
> -----
> import std.conv;
> import std.stdio;
> 
> struct S { }
> 
> void main()
> {
>     S s;
>     writeln(s.text = "foo");
> }
> -----
> 
> This translates into std.conv.text(s, "foo"). I'm not a fan, especially since 'text' is not a @property. But we've already reached the consensus that all functions can be called like properties (for some reason..), so I guess it's too late to change this.

We have? Really?  I haven't been keeping track of all the details, but my last impression was that we agreed that calling non-@property functions with a=b syntax should be illegal.


T

-- 
LINUX = Lousy Interface for Nefarious Unix Xenophobes.
August 27, 2013
On 8/27/13, H. S. Teoh <hsteoh@quickfur.ath.cx> wrote:
> We have? Really?  I haven't been keeping track of all the details, but my last impression was that we agreed that calling non-@property functions with a=b syntax should be illegal.

Oh, maybe you're right! I think I was confusing it with *parentheses*, where a function can be called without parens if it has no arguments.

The 'a = b' syntax, I think that you're right, it won't be accepted for regular functions. (Can Kenji or someone confirm?).

That could definitely make things safer.
August 27, 2013
On Tue, Aug 27, 2013 at 08:40:16PM +0200, Maxim Fomin wrote: [...]
> Let's start from basics:
> 
> writeln = 42;
> 
> and this is also by design.

If that can be called a design at all, it's a horrible design. It should be illegal, if it isn't already. It makes assignment syntax meaningless, and is useful only for obfuscated code contests.


T

-- 
Why have vacation when you can work?? -- EC
August 27, 2013
On 8/27/13, H. S. Teoh <hsteoh@quickfur.ath.cx> wrote:
>> and this is also by design.
>
> If that can be called a design at all, it's a horrible design.

I would call it an accidental implementation detail at best! :)
August 27, 2013
On Tuesday, 27 August 2013 at 19:00:43 UTC, H. S. Teoh wrote:
> On Tue, Aug 27, 2013 at 08:40:16PM +0200, Maxim Fomin wrote:
> [...]
>> Let's start from basics:
>> 
>> writeln = 42;
>> 
>> and this is also by design.
>
> If that can be called a design at all, it's a horrible design. It should
> be illegal, if it isn't already. It makes assignment syntax meaningless,
> and is useful only for obfuscated code contests.
>
>
> T

It wasn't me who invented this :)
August 27, 2013
On Tue, Aug 27, 2013 at 09:40:54PM +0200, Andrej Mitrovic wrote:
> On 8/27/13, H. S. Teoh <hsteoh@quickfur.ath.cx> wrote:
> >> and this is also by design.
> >
> > If that can be called a design at all, it's a horrible design.
> 
> I would call it an accidental implementation detail at best! :)

	Let's call it an accidental feature. -- Larry Wall

:)

That doesn't make it any less ugly, though. I still say we should make func=y syntax illegal for non-@property functions.


T

-- 
Claiming that your operating system is the best in the world because more people use it is like saying McDonalds makes the best food in the world. -- Carl B. Constantine
August 27, 2013
On Tuesday, 27 August 2013 at 19:41:08 UTC, Andrej Mitrovic wrote:
> On 8/27/13, H. S. Teoh <hsteoh@quickfur.ath.cx> wrote:
>>> and this is also by design.
>>
>> If that can be called a design at all, it's a horrible design.
>
> I would call it an accidental implementation detail at best! :)

It was by design, then @property was added and now everyone is confused why it exists. Pretty sure the consensus was to require @property for assignment, but parens were to be optional. At least it seemed to have the least disagreement.