digitalmars.D - DIP32: Uniform tuple syntax
- kenji hara (2/2) Mar 29 2013 http://wiki.dlang.org/DIP32
- Dicebot (3/5) Mar 29 2013 Can't tell at the first read about possible issues, but
- Dmitry Olshansky (22/24) Mar 29 2013 A few typos like:
- kenji hara (14/31) Mar 29 2013 Because it already exists.
- angel (8/8) Mar 29 2013 Another reason to allow swapping values ( {a, b} = {b, a} ) is
- Adam D. Ruppe (7/7) Mar 29 2013 My first thought when I saw {} was json. This is getting a little
- bearophile (6/10) Mar 29 2013 I think Tuple!() has them mostly because there is no handy syntax
- Timon Gehr (4/11) Mar 29 2013 Remove the quotes and it looks like a struct literal.
- Jacob Carlborg (4/7) Mar 29 2013 I agree.
- kenji hara (10/17) Mar 29 2013 For tuple values with named fields, we need more thoughts about semantic...
- bearophile (6/8) Mar 29 2013 Tuples with named fields are records. Once we have a unpacking
- bearophile (9/18) Mar 29 2013 One solution:
- Jacob Carlborg (5/11) Mar 29 2013 I had a proposal of anonymous structs that is similar to this:
- bearophile (101/104) Mar 29 2013 Thank you Kenji for working on this :-)
- bearophile (6/8) Mar 29 2013 That was:
- =?utf-8?Q?Simen_Kj=C3=A6r=C3=A5s?= (11/34) Mar 29 2013 I suggest instead this syntax:
- bearophile (8/28) Mar 29 2013 Telling the language that there there is exactly one item to
- Timon Gehr (3/18) Mar 29 2013 It is already taken and equivalent to:
- Timon Gehr (2/7) Mar 29 2013 It is false.
- bearophile (9/9) Mar 29 2013 Once tuples have a built-in syntax it becomes possible to add
- kenji hara (34/116) Mar 29 2013 It will introduce a kind of "reference variable" to D.
- Zach the Mystic (2/14) Mar 30 2013 {c, ?} = tup;
- bearophile (7/17) Mar 30 2013 Right, I was forgetting that.
- timotheecour (12/28) Apr 05 2013 What about
- bearophile (5/8) Apr 05 2013 I think the question mark is better here. It's shorter and it has
- Zach the Mystic (4/12) Apr 05 2013 Not disagreeing, but you had mentioned nullable types before, and
- bearophile (12/15) Apr 06 2013 I opened this:
- Andrei Alexandrescu (4/18) Apr 06 2013 I think it's safe to close it. Nullable types have not enjoyed a lot of
- bearophile (9/11) Apr 06 2013 On the other hand they have gained appreciation in almost every
- deadalnix (3/12) Apr 06 2013 Non nullable should be the default. Compiler know know how to
- deadalnix (5/33) Apr 06 2013 In C#, all objects are already nullables, which make it not
- Maxim Fomin (13/28) Apr 06 2013 Once dmd pull 1724 is merged, it would be possible to write:
- Timon Gehr (30/32) Mar 29 2013 Looks quite nice. I especially like the {a, b} => ... thing.
- bearophile (6/8) Mar 29 2013 I have suggested to move the ... syntax to a Stage2, a different
- Timon Gehr (4/10) Mar 29 2013 No, please. Slicing should not auto-expand.
- Timon Gehr (3/8) Mar 29 2013 The outer { } are not necessary in order to make the point:
- kenji hara (31/59) Mar 29 2013 It will be parsed as:
- Timon Gehr (18/77) Mar 29 2013 There is no ';', therefore the DIP says it is a tuple brace.
- kenji hara (14/88) Mar 29 2013 Sorry my incomplete description and poor English. I'll improve descripti...
- bearophile (5/8) Mar 29 2013 This is a bad idea. It is not handy and it introduces a special
- kenji hara (14/21) Mar 29 2013 That is "explicit". In D, opened tuple (currently it's generated from
- bearophile (25/41) Mar 29 2013 I (and probably Timon) am just asking for another syntax to do
- Timon Gehr (11/32) Mar 29 2013 Because of prior language limitations, not because it makes any sense!
- Timothee Cour (10/63) Mar 30 2013 not 'open', there is already something called .expand property
- bearophile (7/10) Mar 29 2013 In the end it's not too much bad (despite my first instinct is
- Kagamin (2/6) Mar 31 2013 Should there be a difference?
- Timon Gehr (2/9) Mar 31 2013 Sure.
- bearophile (17/20) Mar 29 2013 You are right, I didn't know/remember about that:
- Timon Gehr (12/14) Mar 29 2013 One quite ugly thing about this is that function arguments will be a
- bearophile (102/109) Mar 29 2013 It's useful to switch on struct values:
- Traveler (6/8) Apr 01 2013 Why not square brackets?
- =?utf-8?Q?Simen_Kj=C3=A6r=C3=A5s?= (16/25) Apr 01 2013 Mostly because it already has a meaning in D, namely that of an array.
- Kagamin (4/4) Apr 01 2013 By the way, {int,int} - is it a type or a value?
- Chris Nicholson-Sauls (15/15) Apr 01 2013 Two different languages I've used in the distant past used @ for
- Jacob Carlborg (4/18) Apr 01 2013 Won't there be a conflict with UDA's?
- Chris Nicholson-Sauls (3/30) Apr 02 2013 Oh yeah, those exist. (I seriously forgot... just because I
- deadalnix (9/11) Apr 06 2013 The {} syntax is already crowded, I don't think this is wise to
- Philip Stuckey (13/15) Aug 13 2014 I'm not sure if this is off topic or redundant but couldn't many
- Dicebot (4/16) Aug 13 2014 This is already possible with standard library but the fact that
- Yota (4/26) Aug 14 2014 Brings to mind C#'s new ability to declare locals within 'out'
- bearophile (5/7) Aug 14 2014 The unpack() lacks most of the capabilities you expect and want
- Sean Kelly (11/11) Aug 14 2014 This looks really nice. I'd love to use it for std.concurrency,
- bearophile (7/11) Aug 14 2014 Elsewhere I have suggested to add to D an optional struct (and
- Jacob Carlborg (5/9) Aug 14 2014 It can be implemented as a library function. The syntax won't be as nice...
- bearophile (6/7) Aug 15 2014 It can't be implemented with a library function. You want to use
- Frustrated (2/4) Aug 15 2014 Will it allow for nested tuples? Or tuples containing lambdas?
On Friday, 29 March 2013 at 08:58:06 UTC, kenji hara wrote:http://wiki.dlang.org/DIP32 Kenji HaraCan't tell at the first read about possible issues, but conceptually - love it, fits nicely.
Mar 29 2013
29-Mar-2013 12:57, kenji hara пишет:http://wiki.dlang.org/DIP32 Kenji HaraA few typos like: {c, $} = tup; // Rewritten as: a = tup[0]; where it should be //Rewritten as c = tup[0]; About swapping values by tuple assignment. Why not simply make this work: {x, y} = {y, x} By lowering {x, y} = {y, x}; to auto temp0 = y; auto temp1 = x; x = temp0; y = temp1; And let the compiler do value propagation to remove the extra temp0. Another note - is there any way to extend this notation to common structs other then .tupleof ? I think we may hopefully extended it later towards struct destructruing a-la EcmaScript 6, see http://wiki.ecmascript.org/doku.php?id=harmony:destructuring All in all it's a great proposal, I'm loving it. -- Dmitry Olshansky
Mar 29 2013
2013/3/29 Dmitry Olshansky <dmitry.olsh gmail.com>A few typos like: {c, $} = tup; // Rewritten as: a = tup[0]; where it should be //Rewritten as c = tup[0];Thanks. Fixed.About swapping values by tuple assignment. Why not simply make this work: {x, y} = {y, x} By lowering {x, y} = {y, x}; to auto temp0 = y; auto temp1 = x; x = temp0; y = temp1; And let the compiler do value propagation to remove the extra temp0.Because it already exists. template Seq(T...) { alias Seq = T; } void main() { int x = 1, y = 2; Seq!(x, y) = Seq!(y, x); // tuple assigmnent assert(x == 2); assert(y == 2); } Another note - is there any way to extend this notation to common structsother then .tupleof ? I think we may hopefully extended it later towards struct destructruing a-la EcmaScript 6, see http://wiki.ecmascript.org/**doku.php?id=harmony:**destructuring<http://wiki.ecmascript.org/doku.php?id=harmony:destructuring>Hmm, interesting. I'll see it later. Kenji Hara
Mar 29 2013
Another reason to allow swapping values ( {a, b} = {b, a} ) is
nice parallel semantics that might provide cool features on some
future (or niche) parallel hardware.
Think of
{a, b} = {funcA(), funcB()};
Parallel semantics is able to evolve to parallel execution, which
is one cool feature.
In Go language it is so.
Mar 29 2013
My first thought when I saw {} was json. This is getting a little
further away from tuples, but would it be hard to add named
fields to this too like json:
auto a = {"foo":12, "bar":"twelve"};
int a_foo = a.foo;
string a_bar = a[1];
The std.typecons Tuple!() can do this kind of thing too.
Mar 29 2013
Adam D. Ruppe:
auto a = {"foo":12, "bar":"twelve"};
int a_foo = a.foo;
string a_bar = a[1];
The std.typecons Tuple!() can do this kind of thing too.
I think Tuple!() has them mostly because there is no handy syntax
to unpack them.
Tuples with field names are records.
Bye,
bearophile
Mar 29 2013
On 03/29/2013 01:49 PM, Adam D. Ruppe wrote:
My first thought when I saw {} was json. This is getting a little
further away from tuples, but would it be hard to add named fields to
this too like json:
auto a = {"foo":12, "bar":"twelve"};
int a_foo = a.foo;
string a_bar = a[1];
The std.typecons Tuple!() can do this kind of thing too.
Remove the quotes and it looks like a struct literal.
I think if named fields are allowed, it should look as follows:
auto a = {foo: 12, bar: "twelve"};
Mar 29 2013
On 2013-03-29 14:26, Timon Gehr wrote:
Remove the quotes and it looks like a struct literal.
I think if named fields are allowed, it should look as follows:
auto a = {foo: 12, bar: "twelve"};
I agree.
--
/Jacob Carlborg
Mar 29 2013
For tuple values with named fields, we need more thoughts about semantics.
alias MyPair = typeof({1, "hi"});
alias MyRecord = typeof({count:1, msg:"hi"});
static assert(is(MyPair == MyRecord)); // true or false?
static assert(is(MyPair : MyRecord)); // true or false?
static assert(is(MyRecord : MyPair)); // true or false?
alias MyStudent = typeof({num:1, name:"John"});
static assert(is(MyRecord == MyStudent)); // true or false?
Kenji Hara
2013/3/29 Adam D. Ruppe <destructionator gmail.com>
My first thought when I saw {} was json. This is getting a little further
away from tuples, but would it be hard to add named fields to this too like
json:
auto a = {"foo":12, "bar":"twelve"};
int a_foo = a.foo;
string a_bar = a[1];
The std.typecons Tuple!() can do this kind of thing too.
Mar 29 2013
On Friday, 29 March 2013 at 14:57:33 UTC, kenji hara wrote:For tuple values with named fields, we need more thoughts about semantics.Tuples with named fields are records. Once we have a unpacking syntax, the names become less needed. I suggest to leave field names to the Stage2. Bye, bearophile
Mar 29 2013
kenji hara:
For tuple values with named fields, we need more thoughts about
semantics.
alias MyPair = typeof({1, "hi"});
alias MyRecord = typeof({count:1, msg:"hi"});
static assert(is(MyPair == MyRecord)); // true or false?
static assert(is(MyPair : MyRecord)); // true or false?
static assert(is(MyRecord : MyPair)); // true or false?
alias MyStudent = typeof({num:1, name:"John"});
static assert(is(MyRecord == MyStudent)); // true or false?
One solution:
http://en.wikipedia.org/wiki/Covariance_and_contravariance_%28computer_science%29
{count:1, "hi"} and {1, msg:"hi"} are invariant.
{count:1, msg:"hi"}, {count:1, "hi"} and {1, msg:"hi"} are
covariant to {1, "hi"}.
But I think it's better to leave this to the Stage2.
Bye,
bearophile
Mar 29 2013
On 2013-03-29 13:49, Adam D. Ruppe wrote:
My first thought when I saw {} was json. This is getting a little
further away from tuples, but would it be hard to add named fields to
this too like json:
auto a = {"foo":12, "bar":"twelve"};
int a_foo = a.foo;
string a_bar = a[1];
I had a proposal of anonymous structs that is similar to this:
http://forum.dlang.org/thread/kfbnuc$1cro$1 digitalmars.com
--
/Jacob Carlborg
Mar 29 2013
kenji hara:http://wiki.dlang.org/DIP32Thank you Kenji for working on this :-) Some comments on your proposal: - - - - - - - - - - - -Use braces and commas. Inside tuple literal, ; never appears. So it will not be confused with lambdas and ScopeStatements.<This is true. On the other hand it's not too much hard to forget a ; or to not see it by mistake. So please let's think well about this important design decision. - - - - - - - - - - - - I presume this will be valid code: auto tup = {10, "hi", 3.14}; assert(tup[0..2] == {10, "hi"}); - - - - - - - - - - - - One handy tuple syntax in Haskell allows you to name both the items of a tuple and it whole: void foo(t2 {int a, string b}) { // here a and b are tuple items and t2 is the whole tuple. } auto t1 {x, y} = {10, "hi"}; foo(t1); - - - - - - - - - - - - auto tup = {}; // zero-element tuple (Syntax meaning will be changed!) Nullary tuples are not that useful in D. Scala doesn't even have a short literal for them. So a longer syntax like this is acceptable: auto tup = Tuple(); - - - - - - - - - - - - This is nice, so we are merging tuple types with tuples, this will simplify D language: // declare tuple value by using explicit tuple type {int, string} tup = {1, "hi"}; alias TL = {int, string[], double[string]}; // types But one thing to remember in the document is that here T1 and T2 are different, because your tuples do not auto-flatten as TypeTuples currently do: alias T1 = {float, double, real}; alias T2 = {float, double, {real}}; - - - - - - - - - - - - foreach (Float; {float, double, real}) { ... } I think you meant to put a variable name there. - - - - - - - - - - - - {1} // one-element tuple I presume this too will be accepted as 1-tuple: {1,} - - - - - - - - - - - - {c, $} = tup; // Rewritten as: c = tup[0]; $ is used for array lengths, so it's not so good to overload it to mean "don't care" too. Alternative syntaxes: {c, $_} = tup; {c, } = tup; {c, _} = tup; {c, $$} = tup; {c, {}} = tup; {c, {_}} = tup; {c, $~} = tup; {c, ~= tup; etc. - - - - - - - - - - - - if (auto {1, y} = tup) { // If the first element of tup (tup[0]) is equal to 1, // y captures the second element of tup (tup[1]). } I suggest to leave that pattern matching plus conditional to a future refinement of tuple implementation (a second stage. And remove it from this first stage proposal. So I suggest to split your proposal in two successive proposals). It seems handy, but D programmers need some time to go there. - - - - - - - - - - - - switch (tup) { case {1, 2}: case {$, 2}: case {1, x}: // capture tup[1] into 'x' when tup[0] == 1 default: // same as {...} } What's quite important here is the "final switch". D has to make sure you are considering all possible cases. - - - - - - - - - - - - I suggest to leave this to the second stage, and remove it from this proposal: auto tup = {1, "hi", 3.14, [1,2,3]}; if (auto {1, "hi", ...} = tup) {} - - - - - - - - - - - - "will" is written badly: // If the first element of coord is equal to 1 (== x), 'then' statement wil be evaluated. - - - - - - - - - - - - I think this is the third thing to leave to the second stage: int x = 1; if (auto {$x, y} = coord) { ... } - - - - - - - - - - - - This is nice: if (auto {x, y} = coord[]) {} // same, explicitly expands fields - - - - - - - - - - - - This is handy and it's vaguely present in Python3, but I suggest to leave this (4th thing) to the second stage: if (auto {num, msg, ...} = tup) {} // ok, `...` matches to zero-elements. - - - - - - - - - - - - Bye, bearophile
Mar 29 2013
{c, {}} = tup;This can't be used, because having an empty tuple as second tuple item is valid.{c, ~= tup;That was: {c, ~} tup; Bye, bearophile
Mar 29 2013
On Fri, 29 Mar 2013 13:56:08 +0100, bearophile <bearophileHUGS lycos.com> wrote:One handy tuple syntax in Haskell allows you to name both the items of a tuple and it whole: void foo(t2 {int a, string b}) { // here a and b are tuple items and t2 is the whole tuple. } auto t1 {x, y} = {10, "hi"}; foo(t1);I suggest instead this syntax: auto {x, y} t1 = {10, "hi"}; It's closer to regular D syntax.foreach (Float; {float, double, real}) { ... } I think you meant to put a variable name there.foreach (Type; {float, double, real}) { ... } See it now?- - - - - - - - - - - - {c, $} = tup; // Rewritten as: c = tup[0]; $ is used for array lengths, so it's not so good to overload it to mean "don't care" too. Alternative syntaxes: {c, $_} = tup; {c, } = tup; {c, _} = tup; {c, $$} = tup; {c, {}} = tup; {c, {_}} = tup; {c, $~} = tup; {c, ~= tup; etc.... has been introduced to match zero or more elements for pattern matching already. I see no reason not to use ... for this. -- Simen
Mar 29 2013
Simen Kjærås:But I'd like sometime to tie t1 to that {}, to help my eyes.void foo(t2 {int a, string b}) { // here a and b are tuple items and t2 is the whole tuple. } auto t1 {x, y} = {10, "hi"}; foo(t1);I suggest instead this syntax: auto {x, y} t1 = {10, "hi"}; It's closer to regular D syntax.Telling the language that there there is exactly one item to match on, that you don't care of, is important. The "..." syntax can't tell apart the case for zero, one, or more items. So "..." can't be enough here. Bye, bearophile{c, $_} = tup; {c, } = tup; {c, _} = tup; {c, $$} = tup; ... {c, {_}} = tup; {c, $~} = tup; ... etc.... has been introduced to match zero or more elements for pattern matching already. I see no reason not to use ... for this.
Mar 29 2013
On 03/29/2013 02:17 PM, Simen Kjærås wrote:On Fri, 29 Mar 2013 13:56:08 +0100, bearophile <bearophileHUGS lycos.com> wrote:It is already taken and equivalent to: {x, y} t1 = {10, "hi"};One handy tuple syntax in Haskell allows you to name both the items of a tuple and it whole: void foo(t2 {int a, string b}) { // here a and b are tuple items and t2 is the whole tuple. } auto t1 {x, y} = {10, "hi"}; foo(t1);I suggest instead this syntax: auto {x, y} t1 = {10, "hi"}; It's closer to regular D syntax. ...
Mar 29 2013
On 03/29/2013 01:56 PM, bearophile wrote:kenji hara:It is false.... Use braces and commas. Inside tuple literal, ; never appears. So it will not be confused with lambdas and ScopeStatements.<This is true. ...
Mar 29 2013
Once tuples have a built-in syntax it becomes possible to add
pairs/byPair to associative arrays:
auto aa = [1:2, 3:4];
{int, int}[] myPairs1 = aa.pairs;
foreach ({k, v}; myPairs1) {}
auto myPairs2 = aa.byPair;
foreach ({k, v}; myPairs2) {}
Bye,
bearophile
Mar 29 2013
2013/3/29 bearophile <bearophileHUGS lycos.com>One handy tuple syntax in Haskell allows you to name both the items of a tuple and it whole: void foo(t2 {int a, string b}) { // here a and b are tuple items and t2 is the whole tuple. } auto t1 {x, y} = {10, "hi"}; foo(t1);It will introduce a kind of "reference variable" to D. auto t1 {x, y} = {10, "hi"}; assert(&t1[0] == &x); // t1[0] and x may refer same address on stack. Such case, you can repeat pack and unpack. void foo({int a, string b}) { // auto t2 = {a, b}; // make tuple by copy, or // {a, b} = {1, 2}; // make pack and use it immediately } auto {x, y} = {10, "hi"}; foo({x, y});auto tup = {}; // zero-element tuple (Syntax meaning will be changed!) Nullary tuples are not that useful in D. Scala doesn't even have a short literal for them. So a longer syntax like this is acceptable: auto tup = Tuple();This is for the consistency of language elements. If you want to zero-parameter lambda, you can write like follows. auto fn = (){}; auto fn = {;};- - - - - - - - - - - - This is nice, so we are merging tuple types with tuples, this will simplify D language: // declare tuple value by using explicit tuple type {int, string} tup = {1, "hi"}; alias TL = {int, string[], double[string]}; // types But one thing to remember in the document is that here T1 and T2 are different, because your tuples do not auto-flatten as TypeTuples currently do: alias T1 = {float, double, real}; alias T2 = {float, double, {real}};It would need more description. I'll explain about that. - - - - - - - - - - - -foreach (Float; {float, double, real}) { ... } I think you meant to put a variable name there.Float is the iterated type.- - - - - - - - - - - - {1} // one-element tuple I presume this too will be accepted as 1-tuple: {1,}Currently D allows redundant commas in some places. void foo(int x, int y,) {} enum E { a = 1, b = 2, } auto arr = [1,2,3,]; So, compiler would accept following tuples. auto tup = {1,}; auto tup = {1,"hi",};- - - - - - - - - - - - {c, $} = tup; // Rewritten as: c = tup[0]; $ is used for array lengths, so it's not so good to overload it to mean "don't care" too. Alternative syntaxes: {c, $_} = tup; {c, } = tup; {c, _} = tup; {c, $$} = tup; {c, {}} = tup; {c, {_}} = tup; {c, $~} = tup; {c, ~= tup; etc.Placeholder token is debatable.- - - - - - - - - - - - if (auto {1, y} = tup) { // If the first element of tup (tup[0]) is equal to 1, // y captures the second element of tup (tup[1]). } I suggest to leave that pattern matching plus conditional to a future refinement of tuple implementation (a second stage. And remove it from this first stage proposal. So I suggest to split your proposal in two successive proposals). It seems handy, but D programmers need some time to go there.For complex tuple unpacking requires the part of pattern matching. auto tup = {1, {2,3,4,5,6}} auto {x, {$, y, ...}} = tup; // makes nested tuple pattern for unpacking assert(x == 1); assert(y == 3); So I'd like to keep one DIP.- - - - - - - - - - - - switch (tup) { case {1, 2}: case {$, 2}: case {1, x}: // capture tup[1] into 'x' when tup[0] == 1 default: // same as {...} } What's quite important here is the "final switch". D has to make sure you are considering all possible cases. - - - - - - - - - - - - I suggest to leave this to the second stage, and remove it from this proposal: auto tup = {1, "hi", 3.14, [1,2,3]}; if (auto {1, "hi", ...} = tup) {} - - - - - - - - - - - - "will" is written badly: // If the first element of coord is equal to 1 (== x), 'then' statement wil be evaluated.Will fix.- - - - - - - - - - - - I think this is the third thing to leave to the second stage: int x = 1; if (auto {$x, y} = coord) { ... } - - - - - - - - - - - - This is nice: if (auto {x, y} = coord[]) {} // same, explicitly expands fields - - - - - - - - - - - - This is handy and it's vaguely present in Python3, but I suggest to leave this (4th thing) to the second stage: if (auto {num, msg, ...} = tup) {} // ok, `...` matches to zero-elements.Kenji Hara
Mar 29 2013
On Friday, 29 March 2013 at 12:56:10 UTC, bearophile wrote:
$ is used for array lengths, so it's not so good to overload it
to mean "don't care" too.
Alternative syntaxes:
{c, $_} = tup;
{c, } = tup;
{c, _} = tup;
{c, $$} = tup;
{c, {}} = tup;
{c, {_}} = tup;
{c, $~} = tup;
{c, ~= tup;
etc.
{c, ?} = tup;
Mar 30 2013
Zach the Mystic:Right, I was forgetting that. Or this if you want to keep the single "?" for hypothetical future nullable types: {c, ?_} = tup; Bye, bearophile{c, $_} = tup; {c, } = tup; {c, _} = tup; {c, $$} = tup; {c, {}} = tup; {c, {_}} = tup; {c, $~} = tup; {c, ~= tup; etc.{c, ?} = tup;
Mar 30 2013
On Saturday, 30 March 2013 at 18:05:27 UTC, bearophile wrote:Zach the Mystic:What about ---- {c, void} = tup; ---- (proposed by Hara Kenji in the original AutoTupleDeclaration declaration pull request https://github.com/D-Programming-Language/dmd/pull/341 ) (and, independently of the missing symbol choice) ---- {a,b,void...} = tup; //tup = {1,2,3,4,5}; ----Right, I was forgetting that. Or this if you want to keep the single "?" for hypothetical future nullable types: {c, ?_} = tup;{c, $_} = tup; {c, } = tup; {c, _} = tup; {c, $$} = tup; {c, {}} = tup; {c, {_}} = tup; {c, $~} = tup; {c, ~= tup; etc.{c, ?} = tup;
Apr 05 2013
timotheecour:
What about
----
{c, void} = tup;
I think the question mark is better here. It's shorter and it has
only one meaning.
Bye,
bearophile
Apr 05 2013
On Friday, 5 April 2013 at 23:49:49 UTC, bearophile wrote:timotheecour:Not disagreeing, but you had mentioned nullable types before, and I was wondering what they might look like also. Have you made an enhancement for these I could examine?What about ---- {c, void} = tup;I think the question mark is better here. It's shorter and it has only one meaning. Bye, bearophile
Apr 05 2013
Zach the Mystic:Not disagreeing, but you had mentioned nullable types before, and I was wondering what they might look like also. Have you made an enhancement for these I could examine?I opened this: http://d.puremagic.com/issues/show_bug.cgi?id=4571 Part of the syntax is: T? means T nullable T = means not nullable. But that ER is a confused mess, and in the meantime the disable was introduced. Now the probability of such nullable syntax+semantics to be introduced in D is very low, so probably I will close down that ER. Bye, bearophile
Apr 06 2013
On 4/6/13 4:10 AM, bearophile wrote:Zach the Mystic:I think it's safe to close it. Nullable types have not enjoyed a lot of AndreiNot disagreeing, but you had mentioned nullable types before, and I was wondering what they might look like also. Have you made an enhancement for these I could examine?I opened this: http://d.puremagic.com/issues/show_bug.cgi?id=4571 Part of the syntax is: T? means T nullable T = means not nullable. But that ER is a confused mess, and in the meantime the disable was introduced. Now the probability of such nullable syntax+semantics to be introduced in D is very low, so probably I will close down that ER. Bye, bearophile
Apr 06 2013
Andrei Alexandrescu:I think it's safe to close it. Nullable types have not enjoyedOn the other hand they have gained appreciation in almost every Java-Like languages running on the JavaVM, so this is a not small failure point of D. I think all type-rich languages that will be designed in future will have nonnullable typing. D is old-school on this. Bye, bearophile
Apr 06 2013
On Saturday, 6 April 2013 at 12:59:53 UTC, bearophile wrote:Andrei Alexandrescu:Non nullable should be the default. Compiler know know how to track initialization.I think it's safe to close it. Nullable types have not enjoyedOn the other hand they have gained appreciation in almost every Java-Like languages running on the JavaVM, so this is a not small failure point of D. I think all type-rich languages that will be designed in future will have nonnullable typing. D is old-school on this.
Apr 06 2013
On Saturday, 6 April 2013 at 12:41:46 UTC, Andrei Alexandrescu wrote:On 4/6/13 4:10 AM, bearophile wrote:really useful. In D, this is implementable as a lib anyway.Zach the Mystic:I think it's safe to close it. Nullable types have not enjoyed AndreiNot disagreeing, but you had mentioned nullable types before, and I was wondering what they might look like also. Have you made an enhancement for these I could examine?I opened this: http://d.puremagic.com/issues/show_bug.cgi?id=4571 Part of the syntax is: T? means T nullable T = means not nullable. But that ER is a confused mess, and in the meantime the disable was introduced. Now the probability of such nullable syntax+semantics to be introduced in D is very low, so probably I will close down that ER. Bye, bearophile
Apr 06 2013









"Dicebot" <m.strashun gmail.com> 