On Saturday, 7 July 2018 at 11:56:40 UTC, rikki cattermole wrote:
void bar (T ...) (T args) if (T.length == 0)
{
return;
[...]
}
void bar (T ...) (T args) if (T.length > 0)
{
writeln (args [0]);
return bar (args [1 .. $]);
}
This is a version without a se
On 7/10/18 7:38 AM, kdevel wrote:
On Tuesday, 10 July 2018 at 00:11:27 UTC, Steven Schveighoffer wrote:
On 7/7/18 7:28 AM, kdevel wrote:
It appears not to be possible to use static if in "guard clause
style" as in
void bar (T ...) (T args)
{
static if (args.length == 0)
On Tuesday, 10 July 2018 at 12:10:27 UTC, Jonathan M Davis wrote:
On Tuesday, 10 July 2018 05:38:33 MDT kdevel via
Digitalmars-d-learn wrote:
I would like to suggest an extension of the language by
introducing
static return Expression_opt;
which shall have the effect of a return plus tha
On Tuesday, 10 July 2018 at 12:05:11 UTC, kdevel wrote:
On Saturday, 7 July 2018 at 13:12:59 UTC, Alex wrote:
The site you cited for the guard clause above (c2.com)
works at runtime.
?
static if works at compile team and only inserts code into the
final code for run-time depending on the co
On Tuesday, 10 July 2018 05:38:33 MDT kdevel via Digitalmars-d-learn wrote:
> I would like to suggest an extension of the language by
> introducing
>
> static return Expression_opt;
>
> which shall have the effect of a return plus that the remaining
> lines in the current block are treated as
On Saturday, 7 July 2018 at 13:12:59 UTC, Alex wrote:
The site you cited for the guard clause above (c2.com)
works at runtime.
?
The intention is to shorten the paths inside a function, I
think. Therefore, a static "guard clause" is a contradiction,
if I understand it correctly.
The term "
On Tuesday, 10 July 2018 05:52:59 MDT kdevel via Digitalmars-d-learn wrote:
> On Saturday, 7 July 2018 at 13:03:32 UTC, rikki cattermole wrote:
> > void func() {
> >
> > return;
> >
> > func2();
> >
> > }
> >
> > Which is clearly an error. Hence why you need to add else block.
>
> There is
On Saturday, 7 July 2018 at 13:03:32 UTC, rikki cattermole wrote:
void func() {
return;
func2();
}
Which is clearly an error. Hence why you need to add else block.
There is no error in this generated code because func2 is
unreachable. That there is a state/stage during compil
On Tuesday, 10 July 2018 at 00:11:27 UTC, Steven Schveighoffer
wrote:
On 7/7/18 7:28 AM, kdevel wrote:
It appears not to be possible to use static if in "guard
clause style" as in
void bar (T ...) (T args)
{
static if (args.length == 0)
return;
writeln (args [0
On 7/7/18 7:28 AM, kdevel wrote:
It appears not to be possible to use static if in "guard clause style"
as in
void bar (T ...) (T args)
{
static if (args.length == 0)
return;
writeln (args [0]);
return bar (args [1 .. $]);
}
Is this intended?
Yes.
On Saturday, 7 July 2018 at 12:54:03 UTC, kdevel wrote:
On Saturday, 7 July 2018 at 12:46:08 UTC, rikki cattermole
wrote:
On 08/07/2018 12:40 AM, kdevel wrote:
Interesting alternative
That was not an alternative.
That is what your code was doing.
What my original code was supposed to do. Bu
On 08/07/2018 12:54 AM, kdevel wrote:
On Saturday, 7 July 2018 at 12:46:08 UTC, rikki cattermole wrote:
On 08/07/2018 12:40 AM, kdevel wrote:
Interesting alternative
That was not an alternative.
That is what your code was doing.
What my original code was supposed to do. But it did not compi
On Saturday, 7 July 2018 at 12:46:08 UTC, rikki cattermole wrote:
On 08/07/2018 12:40 AM, kdevel wrote:
Interesting alternative
That was not an alternative.
That is what your code was doing.
What my original code was supposed to do. But it did not compile.
Error: array index [0] is outsi
On 08/07/2018 12:40 AM, kdevel wrote:
Interesting alternative
That was not an alternative.
That is what your code was doing.
On Saturday, 7 July 2018 at 11:56:40 UTC, rikki cattermole wrote:
On 07/07/2018 11:44 PM, kdevel wrote:
On Saturday, 7 July 2018 at 11:29:35 UTC, rikki cattermole
wrote:
static if (args.length == 0)
return;
else {
writeln (args [0]);
return bar (args [1 .. $]
On 07/07/2018 11:44 PM, kdevel wrote:
On Saturday, 7 July 2018 at 11:29:35 UTC, rikki cattermole wrote:
static if (args.length == 0)
return;
else {
writeln (args [0]);
return bar (args [1 .. $]);
}
That's not guard clause style [1][2].
[1]
https://refact
On Saturday, 7 July 2018 at 11:29:35 UTC, rikki cattermole wrote:
static if (args.length == 0)
return;
else {
writeln (args [0]);
return bar (args [1 .. $]);
}
That's not guard clause style [1][2].
[1]
https://refactoring.com/catalog/replaceNestedConditio
On 07/07/2018 11:28 PM, kdevel wrote:
It appears not to be possible to use static if in "guard clause style"
as in
void bar (T ...) (T args)
{
static if (args.length == 0)
return;
else {
writeln (args [0]);
return bar (args [1 .. $]);
}
}
It appears not to be possible to use static if in "guard clause
style" as in
void bar (T ...) (T args)
{
static if (args.length == 0)
return;
writeln (args [0]);
return bar (args [1 .. $]);
}
Is this intended?
19 matches
Mail list logo