digitalmars.D - Unofficial wish list status.(Nov 2008)
- 4tuu4k002 sneakemail.com (129/129) Oct 31 2008 Hi
- ore-sama (5/9) Nov 01 2008 Provided we have lvalue array literals, this can fit to general array op...
- KennyTM~ (4/15) Nov 01 2008 int code;
- Denis Koroskin (3/18) Nov 01 2008 This is now a tuple, its type is (int,string):
- KennyTM~ (3/25) Nov 01 2008 Right. It should be a tuple instead of an array for more generic variant...
- ore-sama (2/6) Nov 01 2008 Uh... I thought about arrays. For this we need lvalue struct literals.
- Andrei Alexandrescu (4/22) Nov 01 2008 Tuple!(int, "code", string, "msg") getError();
- Denis Koroskin (4/24) Nov 01 2008 Imagine 'code' and 'msg' are already there as local variables and you wa...
- Andrei Alexandrescu (12/41) Nov 01 2008 I've been thinking of defining a simple function that binds to variable
- Denis Koroskin (4/44) Nov 01 2008 Hmmm, this is almost as nice (inspired by jQuery):
- downs (8/63) Nov 03 2008 Sure.
- Robert Fraser (4/70) Nov 03 2008 $(a, b);
- Frits van Bommel (16/26) Nov 01 2008 I've managed to make this work right now:
- bearophile (7/8) Nov 01 2008 [...]
- Andrei Alexandrescu (3/10) Nov 01 2008 Is there a link to online documentation?
- bearophile (6/7) Nov 01 2008 Yes, there is (only because you are one of the most gentle persons of th...
- ore-sama (2/5) Nov 01 2008 this is useless :P use structs or arrays.
- KennyTM~ (2/9) Nov 01 2008 Think of it as another syntactic sugar :p
- bearophile (34/39) Nov 01 2008 With my libs you can do:
Hi This is the monthly status for the unofficial d wish list: http://all-technology.com/eigenpolls/dwishlist/ Right now the wish list looks like this:
Oct 31 2008
4tuu4k002 sneakemail.com Wrote:int, int getPoint(); int a,b; a,b = getPoint();Provided we have lvalue array literals, this can fit to general array operations rules: int[] getPoint(); int a,b; [a,b]=getPoint();
Nov 01 2008
ore-sama wrote:4tuu4k002 sneakemail.com Wrote:int code; string msg; [code, msg] = getError();int, int getPoint(); int a,b; a,b = getPoint();Provided we have lvalue array literals, this can fit to general array operations rules: int[] getPoint(); int a,b; [a,b]=getPoint();
Nov 01 2008
On Sat, 01 Nov 2008 15:00:01 +0300, KennyTM~ <kennytm gmail.com> wrote:ore-sama wrote:This is now a tuple, its type is (int,string): (code, msg) = getError(); // more consistent, but less appealing4tuu4k002 sneakemail.com Wrote:int code; string msg; [code, msg] = getError();int, int getPoint(); int a,b; a,b = getPoint();Provided we have lvalue array literals, this can fit to general array operations rules: int[] getPoint(); int a,b; [a,b]=getPoint();
Nov 01 2008
Denis Koroskin wrote:On Sat, 01 Nov 2008 15:00:01 +0300, KennyTM~ <kennytm gmail.com> wrote:Right. It should be a tuple instead of an array for more generic variants. I think this (x, y) = ... is just as good as [x, y] = ...ore-sama wrote:This is now a tuple, its type is (int,string): (code, msg) = getError(); // more consistent, but less appealing4tuu4k002 sneakemail.com Wrote:int code; string msg; [code, msg] = getError();int, int getPoint(); int a,b; a,b = getPoint();Provided we have lvalue array literals, this can fit to general array operations rules: int[] getPoint(); int a,b; [a,b]=getPoint();
Nov 01 2008
KennyTM~ Wrote:int code; string msg; [code, msg] = getError();Uh... I thought about arrays. For this we need lvalue struct literals.
Nov 01 2008
KennyTM~ wrote:ore-sama wrote:Tuple!(int, "code", string, "msg") getError(); auto e = getError; Andrei4tuu4k002 sneakemail.com Wrote:int code; string msg; [code, msg] = getError();int, int getPoint(); int a,b; a,b = getPoint();Provided we have lvalue array literals, this can fit to general array operations rules: int[] getPoint(); int a,b; [a,b]=getPoint();
Nov 01 2008
On Sat, 01 Nov 2008 19:04:16 +0300, Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> wrote:KennyTM~ wrote:Imagine 'code' and 'msg' are already there as local variables and you want to reuse them. How should you do this?ore-sama wrote:Tuple!(int, "code", string, "msg") getError(); auto e = getError; Andrei4tuu4k002 sneakemail.com Wrote:int code; string msg; [code, msg] = getError();int, int getPoint(); int a,b; a,b = getPoint();Provided we have lvalue array literals, this can fit to general array operations rules: int[] getPoint(); int a,b; [a,b]=getPoint();
Nov 01 2008
Denis Koroskin wrote:On Sat, 01 Nov 2008 19:04:16 +0300, Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> wrote:I've been thinking of defining a simple function that binds to variable addresses and allows assignment from a tuple, in which case the code would be: group(&code, &msg) = getError; In "the future" we'll have variadic ref arguments, in which case the "&"s can be dropped: group(code, msg) = getError; Also in "the future" variable definitions will be expressions, in which case the code to define and assign code and msg becomes: group(int code, string msg) = getError; AndreiKennyTM~ wrote:Imagine 'code' and 'msg' are already there as local variables and you want to reuse them. How should you do this?ore-sama wrote:Tuple!(int, "code", string, "msg") getError(); auto e = getError; Andrei4tuu4k002 sneakemail.com Wrote:int code; string msg; [code, msg] = getError();int, int getPoint(); int a,b; a,b = getPoint();Provided we have lvalue array literals, this can fit to general array operations rules: int[] getPoint(); int a,b; [a,b]=getPoint();
Nov 01 2008
On Sat, 01 Nov 2008 19:33:01 +0300, Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> wrote:Denis Koroskin wrote:Hmmm, this is almost as nice (inspired by jQuery): $(code, msg) = getError(); // :)On Sat, 01 Nov 2008 19:04:16 +0300, Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> wrote:I've been thinking of defining a simple function that binds to variable addresses and allows assignment from a tuple, in which case the code would be: group(&code, &msg) = getError; In "the future" we'll have variadic ref arguments, in which case the "&"s can be dropped: group(code, msg) = getError; Also in "the future" variable definitions will be expressions, in which case the code to define and assign code and msg becomes: group(int code, string msg) = getError; AndreiKennyTM~ wrote:Imagine 'code' and 'msg' are already there as local variables and you want to reuse them. How should you do this?ore-sama wrote:Tuple!(int, "code", string, "msg") getError(); auto e = getError; Andrei4tuu4k002 sneakemail.com Wrote:int code; string msg; [code, msg] = getError();int, int getPoint(); int a,b; a,b = getPoint();Provided we have lvalue array literals, this can fit to general array operations rules: int[] getPoint(); int a,b; [a,b]=getPoint();
Nov 01 2008
Denis Koroskin wrote:On Sat, 01 Nov 2008 19:33:01 +0300, Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> wrote:Sure. $ is not an identifier, but this will work. import tools.base; alias ptuple _; Stuple!(int, string) test() { return stuple(4, "foo"); } void main() { int a; string b; _(a, b) = test(); } :)Denis Koroskin wrote:Hmmm, this is almost as nice (inspired by jQuery): $(code, msg) = getError(); // :)On Sat, 01 Nov 2008 19:04:16 +0300, Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> wrote:I've been thinking of defining a simple function that binds to variable addresses and allows assignment from a tuple, in which case the code would be: group(&code, &msg) = getError; In "the future" we'll have variadic ref arguments, in which case the "&"s can be dropped: group(code, msg) = getError; Also in "the future" variable definitions will be expressions, in which case the code to define and assign code and msg becomes: group(int code, string msg) = getError; AndreiKennyTM~ wrote:Imagine 'code' and 'msg' are already there as local variables and you want to reuse them. How should you do this?ore-sama wrote:Tuple!(int, "code", string, "msg") getError(); auto e = getError; Andrei4tuu4k002 sneakemail.com Wrote:int code; string msg; [code, msg] = getError();int, int getPoint(); int a,b; a,b = getPoint();Provided we have lvalue array literals, this can fit to general array operations rules: int[] getPoint(); int a,b; [a,b]=getPoint();
Nov 03 2008
downs wrote:Denis Koroskin wrote:$(a, b); _(a, b); *has flashbacks to his days in the jungles of Perl*On Sat, 01 Nov 2008 19:33:01 +0300, Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> wrote:Sure. $ is not an identifier, but this will work. import tools.base; alias ptuple _; Stuple!(int, string) test() { return stuple(4, "foo"); } void main() { int a; string b; _(a, b) = test(); } :)Denis Koroskin wrote:Hmmm, this is almost as nice (inspired by jQuery): $(code, msg) = getError(); // :)On Sat, 01 Nov 2008 19:04:16 +0300, Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> wrote:I've been thinking of defining a simple function that binds to variable addresses and allows assignment from a tuple, in which case the code would be: group(&code, &msg) = getError; In "the future" we'll have variadic ref arguments, in which case the "&"s can be dropped: group(code, msg) = getError; Also in "the future" variable definitions will be expressions, in which case the code to define and assign code and msg becomes: group(int code, string msg) = getError; AndreiKennyTM~ wrote:Imagine 'code' and 'msg' are already there as local variables and you want to reuse them. How should you do this?ore-sama wrote:Tuple!(int, "code", string, "msg") getError(); auto e = getError; Andrei4tuu4k002 sneakemail.com Wrote:int code; string msg; [code, msg] = getError();int, int getPoint(); int a,b; a,b = getPoint();Provided we have lvalue array literals, this can fit to general array operations rules: int[] getPoint(); int a,b; [a,b]=getPoint();
Nov 03 2008
Andrei Alexandrescu wrote:I've been thinking of defining a simple function that binds to variable addresses and allows assignment from a tuple, in which case the code would be: group(&code, &msg) = getError; In "the future" we'll have variadic ref arguments, in which case the "&"s can be dropped: group(code, msg) = getError;I've managed to make this work right now: group!(code, msg) = getError(); as well as (with a different function): group_!(code, msg) = getError(); auto myGroup = group_!(code, msg); myGroup = getError(); (The second example has several implementations in fact. Unfortunately, all of them currently allocate a closure for the variables if they're local. The first one doesn't have that problem) All of this is D2+Phobos, by the way. Though something similar could likely be made in D1 (minus the closure issues, obviously). Unfortunately it does have a severe limitation: it only works on straight variables because it uses alias template parameters. You can't assign to *b or foo.a, for instance (unless it's static). See attachment for code.
Nov 01 2008
Frits van Bommel:I've managed to make this work right now:[...] Take a look at the Record!(), record in my libs (for D1), in modules templates and func http://www.fantascienza.net/leonardo/so/libs_d.zip Bye, bearophile
Nov 01 2008
bearophile wrote:Frits van Bommel:Is there a link to online documentation? AndreiI've managed to make this work right now:[...] Take a look at the Record!(), record in my libs (for D1), in modules templates and func http://www.fantascienza.net/leonardo/so/libs_d.zip
Nov 01 2008
Andrei Alexandrescu:Is there a link to online documentation?Yes, there is (only because you are one of the most gentle persons of this newsgroup): http://www.fantascienza.net/leonardo/so/dlibs/all.html The form of that page will improve later. Bye, bearophile
Nov 01 2008
KennyTM~ Wrote:Right. It should be a tuple instead of an array for more generic variants. I think this (x, y) = ... is just as good as [x, y] = ...this is useless :P use structs or arrays.
Nov 01 2008
ore-sama wrote:KennyTM~ Wrote:Think of it as another syntactic sugar :pRight. It should be a tuple instead of an array for more generic variants. I think this (x, y) = ... is just as good as [x, y] = ...this is useless :P use structs or arrays.
Nov 01 2008
ore-sama:KennyTM~ Wrote:With my libs you can do: import d.all; Record!(string, int) foo() { return record("hello"[], 10); } void main() { auto s_i = foo(); putr(s_i.d0, " ", s_i.d1); // Output: hello 10 } Or: import d.all; Record!(string, int) foo() { return record("hello"[], 10); } void main() { string s; int i; derecord(foo(), s, i); putr(s, " ", i); } In D2 the first version will become: import d.all; auto foo() { return record("hello"[], 10); } void main() { auto s_i = foo(); putr(s_i.d0, " ", s_i.d1); // Output: hello 10 } Those Record are structs with several handy methods, they can be joined, cmp, hashed, etc. Even if they recursively contain other kinds of generic structs (not just other Record). With this I don't miss a built-in multiple return too much, while we wait to have it built-in. Bye, bearophileRight. It should be a tuple instead of an array for more generic variants. I think this (x, y) = ... is just as good as [x, y] = ...this is useless :P use structs or arrays.
Nov 01 2008