August 31, 2006
Russ Lewis wrote:
> Walter Bright wrote:
>> Russ Lewis wrote:
>>> Is there any reason to not use "lazy" as a keyword to modify the
>>> expression, rather than the parameter?
>>>
>>>   void foo(int delegate() dg) {...}
>>>   void bar(int x,int y) {
>>>     foo(lazy x+y);
>>>   }
>>
>> One reason is lazy arguments and non-lazy arguments cannot be passed to the same function.
> 
> One of us is missing something.  I'm not sure who :)  Can you expand on your response here?

foo(x + y);
foo(lazy x + y);

can't work, because foo needs to know which it is. Just like you can't have the same parameter be both in and out.
August 31, 2006
Jarrett Billingsley wrote:
> "Kirk McDonald" <kirklin.mcdonald@gmail.com> wrote in message news:ed7ddg$6r2$1@digitaldaemon.com...
> 
>> Nice. I'll have to play with the improved IFTI support.
>>
> 
> Hm.  I missed this new feature.  What does it include?  There's not even a link to a conversation, and I don't remember any threads about this. 

Oskar had emailed me the patches.
August 31, 2006
Oskar Linde wrote:
> Jarrett Billingsley wrote:
> 
>> "Kirk McDonald" <kirklin.mcdonald@gmail.com> wrote in message
>> news:ed7ddg$6r2$1@digitaldaemon.com...
>>
>>> Nice. I'll have to play with the improved IFTI support.
>>>
>> Hm.  I missed this new feature.  What does it include?  There's not even a
>> link to a conversation, and I don't remember any threads about this.
> 
> It is really just a small patch that enables implicit function template
> instantiation for member function and operator templates. It should work
> identically to how IFTI works for free functions. 
> 
> It should open up quite a few door. Here is a quick demo I hacked together
> of how compile time dimensionality checking can be implemented:
> 
> http://www.csc.kth.se/~ol/physical.d

Very, very nice!

> 
> /Oskar
> 
> 
September 01, 2006
"Oskar Linde" <olREM@OVEnada.kth.se> wrote in message news:ed7i39$bke$1@digitaldaemon.com...

> It is really just a small patch that enables implicit function template instantiation for member function and operator templates. It should work identically to how IFTI works for free functions.
>

Ah!!  This exactly solves the problem I was (am!) having with needing several very similar member methods which only differ by the parameter type. Thanks!

> It should open up quite a few door. Here is a quick demo I hacked together of how compile time dimensionality checking can be implemented:
>
> http://www.csc.kth.se/~ol/physical.d

That is really, really cool :)


September 01, 2006
Oskar Linde wrote:
> Jarrett Billingsley wrote:
> 
> 
>>"Kirk McDonald" <kirklin.mcdonald@gmail.com> wrote in message
>>news:ed7ddg$6r2$1@digitaldaemon.com...
>>
>>
>>>Nice. I'll have to play with the improved IFTI support.
>>>
>>
>>Hm.  I missed this new feature.  What does it include?  There's not even a
>>link to a conversation, and I don't remember any threads about this.
> 
> 
> It is really just a small patch that enables implicit function template
> instantiation for member function and operator templates. It should work
> identically to how IFTI works for free functions. 
> 
> It should open up quite a few door. Here is a quick demo I hacked together
> of how compile time dimensionality checking can be implemented:
> 
> http://www.csc.kth.se/~ol/physical.d
> 
> /Oskar
> 
> 


Hot, Dog!!!


This is a project I was hoping to get to a LONG time ago. (The d code side, not the getting-D-to-do-this side)


Best I came up with was a Runtime version.

http://www.webpages.uidaho.edu/~shro8822/unit.d

Mind if I try to graft in a "few" ;) more units and some unittest?
September 01, 2006
Walter Bright wrote:
> Russ Lewis wrote:
> 
>> Walter Bright wrote:
>>
>>> Russ Lewis wrote:
>>>
>>>> Is there any reason to not use "lazy" as a keyword to modify the
>>>> expression, rather than the parameter?
>>>>
>>>>   void foo(int delegate() dg) {...}
>>>>   void bar(int x,int y) {
>>>>     foo(lazy x+y);
>>>>   }
>>>
>>>
>>> One reason is lazy arguments and non-lazy arguments cannot be passed to the same function.
>>
>>
>> One of us is missing something.  I'm not sure who :)  Can you expand on your response here?
> 
> foo(x + y);
> foo(lazy x + y);
> 
> can't work, because foo needs to know which it is. Just like you can't have the same parameter be both in and out.

Ah, I was wondering if that was what you meant.  What I was suggesting was that the code
	lazy x+y
would just be syntax sugar for
	delegate int() { return x+y; }

So, to expand on the previous example:
  void foo(int delegate() dg) {...}
  void foo(int i) {...}
  void bar(int x,int y) {
    foo(lazy x+y); // calls delegate version
    foo(x+y);      // calls int version
  }
September 01, 2006
Russ Lewis wrote:
> Ah, I was wondering if that was what you meant.  What I was suggesting was that the code
>     lazy x+y
> would just be syntax sugar for
>     delegate int() { return x+y; }
> 
> So, to expand on the previous example:
>   void foo(int delegate() dg) {...}
>   void foo(int i) {...}
>   void bar(int x,int y) {
>     foo(lazy x+y); // calls delegate version
>     foo(x+y);      // calls int version
>   }

Ok, that can work. But I don't see an application for it.
September 01, 2006
On Fri, 01 Sep 2006 00:50:48 +0200, Oskar Linde wrote:

> Jarrett Billingsley wrote:
> 
>> "Kirk McDonald" <kirklin.mcdonald@gmail.com> wrote in message news:ed7ddg$6r2$1@digitaldaemon.com...
>> 
>>> Nice. I'll have to play with the improved IFTI support.
>>>
>> 
>> Hm.  I missed this new feature.  What does it include?  There's not even a link to a conversation, and I don't remember any threads about this.
> 
> It is really just a small patch that enables implicit function template instantiation for member function and operator templates. It should work identically to how IFTI works for free functions.
> 
> It should open up quite a few door. Here is a quick demo I hacked together of how compile time dimensionality checking can be implemented:
> 
> http://www.csc.kth.se/~ol/physical.d
> 
> /Oskar

In your example code you have ...

	// One wishes the .toString was unnecessary...
	writefln("A current of ",i.toString);
	writefln("through a voltage of ",v.toString);
	writefln("requires a resistance of ",r.toString);
	writefln("and produces ",w.toString," of heat.");
	writefln("Total energy used in ",ti.toString," is ",e.toString);


but could you not also use ...

	writefln("A current of %s",i);
	writefln("through a voltage of %s",v);
	writefln("requires a resistance of %s",r);
	writefln("and produces %s of heat.",w);
	writefln("Total energy used in %s is %s",ti,e);

-- 
Derek
(skype: derek.j.parnell)
Melbourne, Australia
"Down with mediocrity!"
1/09/2006 12:02:44 PM
September 01, 2006
Derek Parnell wrote:
> On Fri, 01 Sep 2006 00:50:48 +0200, Oskar Linde wrote:
> 
>> Jarrett Billingsley wrote:
>>
>>> "Kirk McDonald" <kirklin.mcdonald@gmail.com> wrote in message
>>> news:ed7ddg$6r2$1@digitaldaemon.com...
>>>
>>>> Nice. I'll have to play with the improved IFTI support.
>>>>
>>> Hm.  I missed this new feature.  What does it include?  There's not even a
>>> link to a conversation, and I don't remember any threads about this.
>> It is really just a small patch that enables implicit function template
>> instantiation for member function and operator templates. It should work
>> identically to how IFTI works for free functions. 
>>
>> It should open up quite a few door. Here is a quick demo I hacked together
>> of how compile time dimensionality checking can be implemented:
>>
>> http://www.csc.kth.se/~ol/physical.d
>>
>> /Oskar
> 
> In your example code you have ...
> 
> 	// One wishes the .toString was unnecessary...
> 	writefln("A current of ",i.toString);
> 	writefln("through a voltage of ",v.toString);
> 	writefln("requires a resistance of ",r.toString);
> 	writefln("and produces ",w.toString," of heat.");
> 	writefln("Total energy used in ",ti.toString," is ",e.toString);
> 
> 
> but could you not also use ...
> 
> 	writefln("A current of %s",i);
> 	writefln("through a voltage of %s",v);
> 	writefln("requires a resistance of %s",r);
> 	writefln("and produces %s of heat.",w);
> 	writefln("Total energy used in %s is %s",ti,e);


Nope, since it only works for classes, and his SiQuantity is a struct
September 01, 2006
On Fri, 01 Sep 2006 04:08:28 +0100, Tom S wrote:

> Derek Parnell wrote:
>> On Fri, 01 Sep 2006 00:50:48 +0200, Oskar Linde wrote:
>> 
>>> Jarrett Billingsley wrote:
>>>
>>>> "Kirk McDonald" <kirklin.mcdonald@gmail.com> wrote in message news:ed7ddg$6r2$1@digitaldaemon.com...
>>>>
>>>>> Nice. I'll have to play with the improved IFTI support.
>>>>>
>>>> Hm.  I missed this new feature.  What does it include?  There's not even a link to a conversation, and I don't remember any threads about this.
>>> It is really just a small patch that enables implicit function template instantiation for member function and operator templates. It should work identically to how IFTI works for free functions.
>>>
>>> It should open up quite a few door. Here is a quick demo I hacked together of how compile time dimensionality checking can be implemented:
>>>
>>> http://www.csc.kth.se/~ol/physical.d
>>>
>>> /Oskar
>> 
>> In your example code you have ...
>> 
>> 	// One wishes the .toString was unnecessary...
>> 	writefln("A current of ",i.toString);
>> 	writefln("through a voltage of ",v.toString);
>> 	writefln("requires a resistance of ",r.toString);
>> 	writefln("and produces ",w.toString," of heat.");
>> 	writefln("Total energy used in ",ti.toString," is ",e.toString);
>> 
>> but could you not also use ...
>> 
>> 	writefln("A current of %s",i);
>> 	writefln("through a voltage of %s",v);
>> 	writefln("requires a resistance of %s",r);
>> 	writefln("and produces %s of heat.",w);
>> 	writefln("Total energy used in %s is %s",ti,e);
> 
> Nope, since it only works for classes, and his SiQuantity is a struct

Damn! I didn't know that. What's the rationale for such a seemingly arbitrary restriction?

-- 
Derek
(skype: derek.j.parnell)
Melbourne, Australia
"Down with mediocrity!"
1/09/2006 1:17:19 PM