[GSoC Proposal] Statically Checked Measurement Units
Cristi Cobzarenco
cristi.cobzarenco at gmail.com
Fri Apr 1 07:53:00 PDT 2011
Ok, my proposal is up, I'm looking forward to feedback.
*fingers crossed*
(Cristi Cobzarenco)
Pofile: http://www.google.com/profiles/cristi.cobzarenco
On 30 March 2011 17:03, Cristi Cobzarenco <cristi.cobzarenco at gmail.com>wrote:
> Hmmm, the only problem with this is that we would have to require the
> library users to do this to their functions. Thanks for the suggestion but
> I'll stick with .mangleof sorting.
> (Cristi Cobzarenco)
> Pofile: http://www.google.com/profiles/cristi.cobzarenco
>
>
> On 30 March 2011 16:49, Andrej Mitrovic <andrej.mitrovich at gmail.com>wrote:
>
>> Maybe OT, but here's some hackish wizardry you can do with classes:
>>
>> class Test
>> {
>> int value;
>>
>> this(int x)
>> {
>> value = x;
>> }
>> }
>>
>> ref Test foo(Test t ...)
>> {
>> return tuple(t)[0];
>> }
>>
>> void main()
>> {
>> auto result = foo(4);
>> assert(result.value == 4);
>> }
>>
>> The Tuple is used to trick DMD into escaping the local `t` reference.
>> This won't work with structs. And `t` should be constructed on the
>> stack, but it seems the destructor gets called only after the exit
>> from main. The docs do say that construction of classes in variadic
>> arguments depend on the implementation.
>>
>> I asked on the newsgroups whether Typesafe Variadic Functions
>> automatically calling a constructor was a good thing at all. Read
>> about this feature here under "Typesafe Variadic Functions":
>> http://www.digitalmars.com/d/2.0/function.html
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20110401/81bb5a39/attachment-0001.html>
More information about the Digitalmars-d
mailing list