[Issue 9062] AddrExp should distinguish the existence of property resolution.

2022-12-17 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=9062

Iain Buclaw  changed:

   What|Removed |Added

   Priority|P2  |P4

--


[Issue 9062] AddrExp should distinguish the existence of property resolution.

2012-12-05 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=9062


Walter Bright bugzi...@digitalmars.com changed:

   What|Removed |Added

 CC||bugzi...@digitalmars.com


--- Comment #13 from Walter Bright bugzi...@digitalmars.com 2012-12-05 
15:30:19 PST ---
C++ has one special case where (e) means something different from e. (Few
people know  that case exists.)

Adding such to D makes me very nervous. I think it's a sound principle that any
expression can be parenthesized without altering its meaning, it's important
for anything that generates source code (like mixins are wont to do).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 9062] AddrExp should distinguish the existence of property resolution.

2012-12-05 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=9062



--- Comment #14 from Kenji Hara k.hara...@gmail.com 2012-12-05 16:26:04 PST 
---
(In reply to comment #13)
 C++ has one special case where (e) means something different from e. (Few
 people know  that case exists.)
 
 Adding such to D makes me very nervous. I think it's a sound principle that 
 any
 expression can be parenthesized without altering its meaning, it's important
 for anything that generates source code (like mixins are wont to do).

It's sure. But, propfunc is one of the key point for the more property
enforcement.

- If propfunc returns an address of returned value, all function related meta
templates will be broken (e.g. FunctionTypeOf).
- If propfunc returns a function pointer of propfunc, all semantics are kept
intact. But, to get an address of returned value from propfunc will become
impossible in range of using built-in-language features.

I have thought a library solution, but this is ugly to me.

import std.algorithm : move;
T identity(T)(T t) { return move(t); }
ref T identity(T)(ref T t) { return t; }

int g;
@property ref int propfunc() { return g; }
void main() {
auto p1 = propfunc;// p1 is function pointer
auto p2 = identity(propfunc);  // p2 is int*
// identity(propfunc) makes an expression,
// then getting an address of returned value can be succeeded.
assert(p2 == g);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 9062] AddrExp should distinguish the existence of property resolution.

2012-12-05 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=9062



--- Comment #15 from Walter Bright bugzi...@digitalmars.com 2012-12-05 
16:37:04 PST ---
I understand the ambiguity issue, and I am not proposing a solution. I'm just
arguing against the e and (e) solution as (perhaps) causing more ambiguity
problems.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 9062] AddrExp should distinguish the existence of property resolution.

2012-11-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=9062


David Nadlinger c...@klickverbot.at changed:

   What|Removed |Added

 CC||c...@klickverbot.at


--- Comment #12 from David Nadlinger c...@klickverbot.at 2012-11-27 10:50:27 
PST ---
I would not worry to much about @trusted: In my �@trusted considered harmful�
thread from a while back
(http://forum.dlang.org/thread/blrglebkzhrilxkbp...@forum.dlang.org), nobody
could come up with a reason for keeping it part of the interface. I just didn't
get around to writing a DIP resp. implementing it in DMD yet.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 9062] AddrExp should distinguish the existence of property resolution.

2012-11-25 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=9062



--- Comment #11 from Kenji Hara k.hara...@gmail.com 2012-11-25 01:51:06 PST 
---
(In reply to comment #10)
 I am not sure what you are trying to do here. Anyways, the following should
 work:
 
 template PropertyTypeOf(alias prop) {
 alias PropertyTypeOf = typeof(()auto ref=prop);
 }

My try is an emulation of your idea. I found two problems at least.

1. In a way that uses template function attribute deduction, getting the
@trusted attribute is impossible, because it is deduced to @safe.

2. Cannot get function type from member property function, because of 'need
this' error.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 9062] AddrExp should distinguish the existence of property resolution.

2012-11-23 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=9062


d...@dawgfoto.de changed:

   What|Removed |Added

 CC||d...@dawgfoto.de


--- Comment #3 from d...@dawgfoto.de 2012-11-23 03:30:57 PST ---
If @property is all about equivalence of fields and accessors, then foo should
not return a function pointer. IMHO obtaining the funtion pointer should be the
special case.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 9062] AddrExp should distinguish the existence of property resolution.

2012-11-23 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=9062



--- Comment #4 from Kenji Hara k.hara...@gmail.com 2012-11-23 04:57:35 PST ---
(In reply to comment #3)
 If @property is all about equivalence of fields and accessors, then foo 
 should
 not return a function pointer.

Then, there is no way to get a function pointer from property function, right?


 IMHO obtaining the funtion pointer should be the
 special case.

std.traits.FunctionTypeOf!(property_func) is a special case?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 9062] AddrExp should distinguish the existence of property resolution.

2012-11-23 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=9062


timon.g...@gmx.ch changed:

   What|Removed |Added

 CC||timon.g...@gmx.ch


--- Comment #5 from timon.g...@gmx.ch 2012-11-23 05:00:33 PST ---
Property functions should always be called regardless of context.

int g;
@property ref int foo() { return g; }

pragma(msg, typeof(  foo  ));  // will print int*
pragma(msg, typeof( (foo) ));  // will print int*

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 9062] AddrExp should distinguish the existence of property resolution.

2012-11-23 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=9062



--- Comment #6 from timon.g...@gmx.ch 2012-11-23 05:04:00 PST ---
(In reply to comment #4)
 (In reply to comment #3)
  If @property is all about equivalence of fields and accessors, then foo 
  should
  not return a function pointer.
 
 Then, there is no way to get a function pointer from property function, right?
 ...

()ref = foo

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 9062] AddrExp should distinguish the existence of property resolution.

2012-11-23 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=9062



--- Comment #7 from Kenji Hara k.hara...@gmail.com 2012-11-23 05:32:10 PST ---
(In reply to comment #6)
  Then, there is no way to get a function pointer from property function, 
  right?
  ...
 
 ()ref = foo

It looks like a lambda. Is it same as this?

  ref __lambda() { return foo; }

But, on the return statement, foo is translated to foo(). It seems not
possible.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 9062] AddrExp should distinguish the existence of property resolution.

2012-11-23 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=9062



--- Comment #8 from timon.g...@gmx.ch 2012-11-23 05:41:30 PST ---
(In reply to comment #7)
 (In reply to comment #6)
   Then, there is no way to get a function pointer from property function, 
   right?
   ...
  
  ()ref = foo
 
 It looks like a lambda. Is it same as this?
 
   ref __lambda() { return foo; }
 

Yes, it is the same as __lambda, where __lambda is

static ref __lambda() { return foo; }

(the fact that the parser chokes on ref-qualified function/delegate literals
and function/delegate types is another bug.)

 But, on the return statement, foo is translated to foo(). It seems not
 possible.

__lambda is a function pointer.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 9062] AddrExp should distinguish the existence of property resolution.

2012-11-23 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=9062



--- Comment #9 from Kenji Hara k.hara...@gmail.com 2012-11-23 06:06:46 PST ---
(In reply to comment #8)
[snip]

OK, I understood what you say. But implementing it in library might be much
difficult...

---
// An experimental implementation of timon's idea.
template PropertyTypeOf(alias prop)
{
auto ref wrapper()(){ return prop(); }
alias PropertyTypeOf = typeof(wrapper!());
}

/*@property*/ int foo() @trusted nothrow { return 10;}
pragma(msg, PropertyTypeOf!foo);
// - int function() nothrow @safe  (not @trusted)

void main()
{
struct S { /*@property*/ string bar() pure { return ; } }
pragma(msg, PropertyTypeOf!(S.bar));
// - Error...
}
---

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 9062] AddrExp should distinguish the existence of property resolution.

2012-11-23 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=9062



--- Comment #10 from timon.g...@gmx.ch 2012-11-23 06:54:28 PST ---
(In reply to comment #9)
 (In reply to comment #8)
 [snip]
 
 OK, I understood what you say. But implementing it in library might be much
 difficult...
 
 ---
 // An experimental implementation of timon's idea.
 template PropertyTypeOf(alias prop)
 {
 auto ref wrapper()(){ return prop(); }
 alias PropertyTypeOf = typeof(wrapper!());
 }
 
 /*@property*/ int foo() @trusted nothrow { return 10;}
 pragma(msg, PropertyTypeOf!foo);
 // - int function() nothrow @safe  (not @trusted)
 
 void main()
 {
 struct S { /*@property*/ string bar() pure { return ; } }
 pragma(msg, PropertyTypeOf!(S.bar));
 // - Error...
 }
 ---

I am not sure what you are trying to do here. Anyways, the following should
work:

template PropertyTypeOf(alias prop) {
alias PropertyTypeOf = typeof(()auto ref=prop);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 9062] AddrExp should distinguish the existence of property resolution.

2012-11-22 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=9062



--- Comment #1 from github-bugzi...@puremagic.com 2012-11-22 22:24:20 PST ---
Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/2897ca8807d6ab54fc2c983325104b96d1bda10e
fix Issue 9062 - AddrExp should distinguish the existence of property
resolution

https://github.com/D-Programming-Language/phobos/commit/1ce5ca470a4520d1c3956e14ec3e8dfb4fcd907f
Merge pull request #966 from 9rnsr/fix9062

Supplemental fix for Issue 9062 - AddrExp should distinguish the existence of
property resolution

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---