switch (cond)
common: always executed code here
case A : etc...
}
instead of
if (cond) { always executed code here }
switch (cond)
case A : etc...
}
which requires modification of the condition twice when necessary
On Saturday, 3 August 2013 at 14:38:48 UTC, JS wrote:
switch (cond)
common: always executed code here
case A : etc...
}
instead of
if (cond) { always executed code here }
switch (cond)
case A : etc...
}
which requires modification of the condition twice when
ne
On Saturday, 3 August 2013 at 14:38:48 UTC, JS wrote:
switch (cond)
common: always executed code here
case A : etc...
}
instead of
if (cond) { always executed code here }
switch (cond)
case A : etc...
}
which requires modification of the condition twice when
ne
Am 03.08.2013 16:38, schrieb JS:
switch (cond)
common: always executed code here
case A : etc...
}
instead of
if (cond) { always executed code here }
switch (cond)
case A : etc...
}
which requires modification of the condition twice when necessary
s
On 8/3/13 11:38 AM, JS wrote:
switch (cond)
common: always executed code here
case A : etc...
}
instead of
if (cond) { always executed code here }
switch (cond)
case A : etc...
}
which requires modification of the condition twice when necessary
Do you mea
On Saturday, 3 August 2013 at 16:16:24 UTC, Ary Borenszweig wrote:
On 8/3/13 11:38 AM, JS wrote:
switch (cond)
common: always executed code here
case A : etc...
}
instead of
if (cond) { always executed code here }
switch (cond)
case A : etc...
}
which requires
On 8/3/13 10:21 AM, JS wrote:
On Saturday, 3 August 2013 at 16:16:24 UTC, Ary Borenszweig wrote:
On 8/3/13 11:38 AM, JS wrote:
switch (cond)
common: always executed code here
case A : etc...
}
instead of
if (cond) { always executed code here }
switch (cond)
case A : etc
I can see you saving a little bit of typing with this, but it's
not worth it.
On 8/3/2013 10:45 AM, w0rp wrote:
I can see you saving a little bit of typing with this, but it's
not worth it.
It would be a very unconventional syntactic form, and my experience with such
things is it'll see very, very little use.
On Saturday, 3 August 2013 at 18:04:03 UTC, Walter Bright wrote:
On 8/3/2013 10:45 AM, w0rp wrote:
I can see you saving a little bit of typing with this, but it's
not worth it.
It would be a very unconventional syntactic form, and my
experience with such things is it'll see very, very little
On Saturday, 3 August 2013 at 17:45:11 UTC, w0rp wrote:
I can see you saving a little bit of typing with this, but it's
not worth it.
Um, it can actually save a lot of type and errors.
having two places to change is very error prone.
if (cond) { }
switch(cond)
If the condition is complex an
On Saturday, 3 August 2013 at 18:51:24 UTC, MattCoder wrote:
On Saturday, 3 August 2013 at 18:04:03 UTC, Walter Bright wrote:
On 8/3/2013 10:45 AM, w0rp wrote:
I can see you saving a little bit of typing with this, but
it's
not worth it.
It would be a very unconventional syntactic form, and
On Saturday, 3 August 2013 at 18:56:47 UTC, JS wrote:
On Saturday, 3 August 2013 at 17:45:11 UTC, w0rp wrote:
I can see you saving a little bit of typing with this, but it's
not worth it.
Um, it can actually save a lot of type and errors.
having two places to change is very error prone.
if
On Saturday, 3 August 2013 at 19:10:19 UTC, Andre Artus wrote:
If the implementation is so obviously trivial why don't you
implement a proof of concept? The compiler is open source after
all.
This seems like something that would be fairly simple to
implement using a mixin template, so you may
On 8/3/2013 12:00 PM, JS wrote:
What I really don't get it is why people think that just because they won't use
such a feature then it must be useless to everyone else.
You could provide supporting evidence by examining every use of switch in the
dmd, phobos, and druntime source code, and see
On Sat, Aug 03, 2013 at 12:22:53PM -0700, Walter Bright wrote:
> On 8/3/2013 12:00 PM, JS wrote:
> >What I really don't get it is why people think that just because they
> >won't use such a feature then it must be useless to everyone else.
>
> You could provide supporting evidence by examining eve
On Saturday, 3 August 2013 at 19:10:19 UTC, Andre Artus wrote:
On Saturday, 3 August 2013 at 18:56:47 UTC, JS wrote:
On Saturday, 3 August 2013 at 17:45:11 UTC, w0rp wrote:
I can see you saving a little bit of typing with this, but
it's
not worth it.
Um, it can actually save a lot of type a
On Saturday, 3 August 2013 at 19:51:33 UTC, JS wrote:
...
I am afraid creating your own language may be your only
possibility to get a language that shares your views on "proper"
design. Because with each new topic it becomes more and more
clear that D is unlikely to fit into that picture.
On Saturday, 3 August 2013 at 19:22:53 UTC, Walter Bright wrote:
On 8/3/2013 12:00 PM, JS wrote:
What I really don't get it is why people think that just
because they won't use
such a feature then it must be useless to everyone else.
You could provide supporting evidence by examining every us
On Saturday, August 03, 2013 12:35:22 H. S. Teoh wrote:
> On Sat, Aug 03, 2013 at 12:22:53PM -0700, Walter Bright wrote:
> > On 8/3/2013 12:00 PM, JS wrote:
> > >What I really don't get it is why people think that just because they
> > >won't use such a feature then it must be useless to everyone e
Regarding the feature proposed here, I think the extra complexity
added doesn't pay enough back.
Walter Bright:
You could provide supporting evidence by examining every use of
switch in the dmd, phobos, and druntime source code, and see
what percentage of those would benefit from your propos
On Sat, Aug 03, 2013 at 01:33:44PM -0700, Jonathan M Davis wrote:
> On Saturday, August 03, 2013 12:35:22 H. S. Teoh wrote:
> > On Sat, Aug 03, 2013 at 12:22:53PM -0700, Walter Bright wrote:
[...]
> > > Consider, for example, the scope guard statement in D. It is
> > > extremely useful - but it is
On Saturday, August 03, 2013 14:25:24 H. S. Teoh wrote:
> On Sat, Aug 03, 2013 at 01:33:44PM -0700, Jonathan M Davis wrote:
> > The only thing that's really missing from C++ that D has that you
> > might use in place of scope is finally.
>
> Truth be told, I think scope trumps finally because it l
On 8/3/2013 1:06 PM, JS wrote:
On Saturday, 3 August 2013 at 19:22:53 UTC, Walter Bright wrote:
On 8/3/2013 12:00 PM, JS wrote:
What I really don't get it is why people think that just because they won't use
such a feature then it must be useless to everyone else.
You could provide supporting
On 8/3/2013 12:51 PM, JS wrote:
On Saturday, 3 August 2013 at 19:10:19 UTC, Andre Artus wrote:
If the implementation is so obviously trivial why don't you implement a proof
of concept?
because I have better things to do
Implying that our time is of lesser value than yours does not help sell y
On Sat, Aug 03, 2013 at 02:34:51PM -0700, Jonathan M Davis wrote:
> On Saturday, August 03, 2013 14:25:24 H. S. Teoh wrote:
> > On Sat, Aug 03, 2013 at 01:33:44PM -0700, Jonathan M Davis wrote:
[...]
> > > I definitely use scope from time to time, but I don't know how
> > > frequently I use it in c
On Saturday, August 03, 2013 14:49:30 H. S. Teoh wrote:
> On Sat, Aug 03, 2013 at 02:34:51PM -0700, Jonathan M Davis wrote:
> > On Saturday, August 03, 2013 14:25:24 H. S. Teoh wrote:
> > > On Sat, Aug 03, 2013 at 01:33:44PM -0700, Jonathan M Davis wrote:
> [...]
>
> > > > I definitely use scope f
On Saturday, 3 August 2013 at 21:42:00 UTC, Walter Bright wrote:
On 8/3/2013 12:51 PM, JS wrote:
On Saturday, 3 August 2013 at 19:10:19 UTC, Andre Artus wrote:
If the implementation is so obviously trivial why don't you
implement a proof
of concept?
because I have better things to do
Implyi
So, depending on how you define "not worth it", which I take
"I'm too lazy to implement it", you could be correct.
YaAA:
If the implementation is so obviously trivial why don't you
implement a proof of concept? The compiler is open source
after all.
JS:
because I have better things to do a
On Saturday, 3 August 2013 at 18:56:47 UTC, JS wrote:
Um, it can actually save a lot of type and errors.
having two places to change is very error prone.
if (cond) { }
switch(cond)
What is error-prone is evaluation of a complex condition twice
assuming it will result in the same value. That'
On Sunday, 4 August 2013 at 01:57:04 UTC, JS wrote:
Stuff like i++(short form) is ONLY for convenience... yet every
uses it! NOT because they used it before it exists(obviously)
but because the language supported it and then people were able
to see how useful it is(and some things take a long t
On Sat, Aug 03, 2013 at 03:18:49PM -0700, Jonathan M Davis wrote:
[...]
> Hmmm. For a scope(success) statement to work, the code has to be put
> at every successful exit point from the scope. In the simple case,
> that means putting it at the end of the try portion of a try-catch
> block, but the t
On Saturday, 3 August 2013 at 20:38:37 UTC, bearophile wrote:
Regarding the feature proposed here, I think the extra
complexity added doesn't pay enough back.
Walter Bright:
You could provide supporting evidence by examining every use
of switch in the dmd, phobos, and druntime source code, a
On Sunday, 4 August 2013 at 15:32:17 UTC, monarch_dodra wrote:
You pique my interest. What is this? Looks like template
shorthand? I didn't find nything about it in docs. Could you
share some links about this?
http://wiki.dlang.org/DIP42
On Sunday, 4 August 2013 at 10:14:50 UTC, Kagamin wrote:
On Saturday, 3 August 2013 at 18:56:47 UTC, JS wrote:
Um, it can actually save a lot of type and errors.
having two places to change is very error prone.
if (cond) { }
switch(cond)
What is error-prone is evaluation of a complex conditi
On Sunday, 4 August 2013 at 15:57:32 UTC, Andre Artus wrote:
On Sunday, 4 August 2013 at 10:14:50 UTC, Kagamin wrote:
On Saturday, 3 August 2013 at 18:56:47 UTC, JS wrote:
Um, it can actually save a lot of type and errors.
having two places to change is very error prone.
if (cond) { }
switch(
On Sunday, 4 August 2013 at 16:16:25 UTC, Andre Artus wrote:
On Sunday, 4 August 2013 at 15:57:32 UTC, Andre Artus wrote:
On Sunday, 4 August 2013 at 10:14:50 UTC, Kagamin wrote:
On Saturday, 3 August 2013 at 18:56:47 UTC, JS wrote:
Um, it can actually save a lot of type and errors.
having tw
On 08/03/2013 01:38 PM, bearophile wrote:
> enum mysize(T) = T.sizeof;
That works...
> template Pair(T) = Tuple(T, T);
Instead, the following works (alias and !):
alias Pair(T) = Tuple!(T, T);
Is my change right?
Ali
Ali Çehreli:
> template Pair(T) = Tuple(T, T);
Instead, the following works (alias and !):
alias Pair(T) = Tuple!(T, T);
Is my change right?
Your change is right, I didn't give enough attention on the code
I wrote, sorry :-)
Bye,
bearophile
On Sunday, 4 August 2013 at 15:38:01 UTC, Dicebot wrote:
On Sunday, 4 August 2013 at 15:32:17 UTC, monarch_dodra wrote:
You pique my interest. What is this? Looks like template
shorthand? I didn't find nything about it in docs. Could you
share some links about this?
http://wiki.dlang.org/DIP4
monarch_dodra:
Awesome. I'll have to introduce std.traits to this new syntax.
That DIP is not updated to what was actually implemented by
Kenji. There is support for both enum and alias.
But after a good look at my code base I have not found many
places where the new syntax is useful. In m
On 8/4/2013 11:30 AM, bearophile wrote:
monarch_dodra:
Awesome. I'll have to introduce std.traits to this new syntax.
That DIP is not updated to what was actually implemented by Kenji. There is
support for both enum and alias.
But after a good look at my code base I have not found many place
Andre Artus:
int number;
string message;
switch (number)
{
default: // valid: ends with 'throw'
throw new Exception("unknown number");
case 3:
message ~= "three "; break;
case 4:
message ~= "four "; continue;
case 5:
On Monday, 5 August 2013 at 04:07:55 UTC, Andre Artus wrote:
Andre Artus:
int number;
string message;
switch (number)
{
default: // valid: ends with 'throw'
throw new Exception("unknown number");
case 3:
message ~= "three "; break;
case 4:
perhaps a more generic solution should be looked at, extend
contracts to work with all scope blocks.
switch(somenumber)
in {
... before stuff ...
}
out {
after stuff ...
}
body {
case 1:
in {
... etc
}
out {
... more etc ...
}
body {
On Monday, 5 August 2013 at 06:28:12 UTC, luminousone wrote:
perhaps a more generic solution should be looked at, extend
contracts to work with all scope blocks.
switch(somenumber)
in {
... before stuff ...
}
out {
after stuff ...
}
body {
case 1:
in {
... etc
Am 05.08.2013 08:28, schrieb luminousone:
or perhaps
for( int i = 0 ; i < 10 ; i ++ )
in {
assert( i == 0 );
}
out {
assert( i == 9 );
}
body {
... stuff ...
}
that is just evil code
if you got something todo before or on the first item of the list do it
before the loop - an
On Monday, 5 August 2013 at 04:07:55 UTC, Andre Artus wrote:
Andre Artus:
int number;
string message;
switch (number)
{
default: // valid: ends with 'throw'
throw new Exception("unknown number");
case 3:
message ~= "three "; break;
case 4:
On Monday, 5 August 2013 at 09:37:11 UTC, dennis luehring wrote:
this type of sub-branching "de-looping" is slow (if performance
is relevant) and just not foreach-able, and so not
functional-style programming - its called "for loop index micro
management for unknown reasons" - but many program
On Monday, 5 August 2013 at 11:32:14 UTC, QAston wrote:
On Monday, 5 August 2013 at 09:37:11 UTC, dennis luehring wrote:
this type of sub-branching "de-looping" is slow (if
performance is relevant) and just not foreach-able, and so not
functional-style programming - its called "for loop index
Andre Artus:
It may not always be the case, but in my experience this often
leads to write-only code.
I'm pretty new to D, so I'm not quite up to speed with the
metaprogramming abilities, but I'm under the impression that
this is what mixin's are for.
MattCoder:
Well I'm not experienced to
On Monday, 5 August 2013 at 09:37:11 UTC, dennis luehring wrote:
Am 05.08.2013 08:28, schrieb luminousone:
or perhaps
for( int i = 0 ; i < 10 ; i ++ )
in {
assert( i == 0 );
}
out {
assert( i == 9 );
}
body {
... stuff ...
}
that is just evil code
if you got something todo befo
On Monday, 5 August 2013 at 08:46:54 UTC, Andre Artus wrote:
On Monday, 5 August 2013 at 06:28:12 UTC, luminousone wrote:
perhaps a more generic solution should be looked at, extend
contracts to work with all scope blocks.
switch(somenumber)
in {
... before stuff ...
}
out {
after s
On Monday, 5 August 2013 at 19:58:21 UTC, ron wrote:
On Monday, 5 August 2013 at 08:46:54 UTC, Andre Artus wrote:
On Monday, 5 August 2013 at 06:28:12 UTC, luminousone wrote:
perhaps a more generic solution should be looked at, extend
contracts to work with all scope blocks.
switch(somenumber
On Monday, 5 August 2013 at 20:45:47 UTC, Borislav Kosharov wrote:
On Monday, 5 August 2013 at 19:58:21 UTC, ron wrote:
On Monday, 5 August 2013 at 08:46:54 UTC, Andre Artus wrote:
On Monday, 5 August 2013 at 06:28:12 UTC, luminousone wrote:
perhaps a more generic solution should be looked at,
On Monday, 5 August 2013 at 19:58:21 UTC, ron wrote:
On Monday, 5 August 2013 at 08:46:54 UTC, Andre Artus wrote:
On Monday, 5 August 2013 at 06:28:12 UTC, luminousone wrote:
perhaps a more generic solution should be looked at, extend
contracts to work with all scope blocks.
switch(somenumber
Borislav Kosharov wrote:
Speaking of contracts, and reading the docs I see:
"Pre and Post Contracts
The pre contracts specify the preconditions before a statement
is executed. The most typical use of this would be in
validating the parameters to a function. The post contracts
validate the res
On Monday, 5 August 2013 at 21:48:46 UTC, Andre Artus wrote:
On Monday, 5 August 2013 at 19:58:21 UTC, ron wrote:
On Monday, 5 August 2013 at 08:46:54 UTC, Andre Artus wrote:
On Monday, 5 August 2013 at 06:28:12 UTC, luminousone wrote:
perhaps a more generic solution should be looked at, extend
As Andrei points out in his book ("The D Programming
Language") contracts are not used to validate/scrub user (or
any external) input as they can be compiled out of the
executable.
Contracts are there to check sanity at compile time, or at the
very least during testing.
The contract is (or
On Saturday, 3 August 2013 at 19:22:53 UTC, Walter Bright wrote:
On 8/3/2013 12:00 PM, JS wrote:
What I really don't get it is why people think that just
because they won't use
such a feature then it must be useless to everyone else.
You could provide supporting evidence by examining every us
I was under the impression that D has nested functions, unless
by inner function you mean something else.
Yeah, pardon my terminology.
On Tuesday, 6 August 2013 at 07:44:46 UTC, QAston wrote:
I was under the impression that D has nested functions, unless
by inner function you mean something else.
Yeah, pardon my terminology.
Not an issue, they normally mean the same thing. I believe JS's
use case can be covered easily and c
62 matches
Mail list logo