PyD
Jonathan M Davis
jmdavisProg at gmx.com
Thu Feb 23 22:06:21 PST 2012
On Thursday, February 23, 2012 23:52:09 Ellery Newcomer wrote:
> On 02/23/2012 11:40 PM, Ellery Newcomer wrote:
> > Well, I can't make any promises, but you can try this:
> >
> > https://bitbucket.org/ariovistus/pyd
> >
> > it seems not to be compiling with the 2.058 front end, but I think it
> > should with the 2.057 front end and ldc.
>
> crumb, I take that back
>
> Anyone know why following code gives
>
> test.d(5): Error: f.fn() is not an lvalue
>
>
>
> import std.traits;
> template _py(Dg){
> Dg func(){
> F f = new F();
> return &f.fn!(ReturnType!Dg);
> }
> }
>
> class F{
> Tr fn(Tr, T ...)(T t){
> }
> }
>
> void main(){
> alias _py!(void delegate()) tz;
> }
Because like the error says, it's not an lvalue. fn returns a Tr, not a ref
Tr. It's a temporary. And you can't take the address of a temporary.
Even worse, it looks like Tr is actually void, because fn is being passed
ReturnType!Dg, and the delegate passed in is void. So, fn returns void, and
then func tries to take the address of a void return value, which makes no
sense.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list