On Sunday, 14 October 2018 at 15:27:07 UTC, Michael Coulombe
wrote:
On Sunday, 14 October 2018 at 14:35:36 UTC, lngns wrote:
On Sunday, 14 October 2018 at 13:18:37 UTC, lngns wrote:
That would require introducing a new type
Or just use int with a negative number... That's how it's done
in
On Sunday, 14 October 2018 at 14:35:36 UTC, lngns wrote:
On Sunday, 14 October 2018 at 13:18:37 UTC, lngns wrote:
That would require introducing a new type
Or just use int with a negative number... That's how it's done
in some dynamic languages.
But my point is that it should be compatible
On Sunday, 14 October 2018 at 13:18:37 UTC, lngns wrote:
That would require introducing a new type
Or just use int with a negative number... That's how it's done in
some dynamic languages.
But my point is that it should be compatible with pre-existing
code using unsigned indices somehow. I
On Wednesday, 10 October 2018 at 13:32:15 UTC, Simen Kjærås wrote:
struct Sentinel {}
Sentinel $;
void foo(T)(T loc) {
auto bar = double[RandomPInt+1];
static if (is(T == Sentinel)) {
return bar[$];
} else {
return bar[loc];
}
}
unittest {
foo($);
}
It
On 10/11/2018 04:36 AM, Dejan Lekic wrote:
On Thursday, 11 October 2018 at 06:58:08 UTC, Simen Kjærås wrote:
unittest {
auto x = fun($); // What does it even mean?
}
After some reading through the whole thread I think his "$ idea" can
only be applied to a RandomAccessRange (and similar)
On Thursday, 11 October 2018 at 00:01:27 UTC, James Japherson
wrote:
I don't understand why you need to be convinced that this is
relevant.
Do you not realize that there are cases where one wants to
select the last element of a list without having to explicitly
know it?
It's fine if you
On Thursday, 11 October 2018 at 06:58:08 UTC, Simen Kjærås wrote:
unittest {
auto x = fun($); // What does it even mean?
}
After some reading through the whole thread I think his "$ idea"
can only be applied to a RandomAccessRange (and similar) where
the size can be known...
On Wednesday, 10 October 2018 at 23:04:46 UTC, James Japherson
wrote:
The whole point is not to use $ as an identifier but to specify
to the compiler of that it can rewrite it.
I know. I'm pointing out that as syntactic sugar, it can't be
passed as an int.
You seem to think that what the
On Wednesday, 10 October 2018 at 23:04:46 UTC, James Japherson
wrote:
The whole point is not to use $ as an identifier but to specify
to the compiler of that it can rewrite it.
It's called 'alias'.
// compile time
int foo(alias index)(int[] a)
{
return a[index(a.length)];
}
// run
On 10/10/2018 05:01 PM, James Japherson wrote:
All I'm proposing is to to allow one to escape that syntax to function
calls.
foo(int index)
{
return arr[index];
}
and D can support
foo($-1);
which simply gets translated in to
arr[arr.length - 1]
I think you might have a
On Wednesday, 10 October 2018 at 08:46:42 UTC, James Japherson
wrote:
Would be nice to be able to pass $ as a function argument to be
used in automatic path length traversing.
You can already do this, by returning a custom type from opDollar:
/// Define RealNumbers so that, given `RealNumbers
On Wednesday, 10 October 2018 at 23:26:38 UTC, Dennis wrote:
Can you give a real-world, non-foo/bar example where you want
to use it? I have trouble understanding what you want to
accomplish.
I don't understand why you need to be convinced that this is
relevant.
Do you not realize that
Can you give a real-world, non-foo/bar example where you want to
use it? I have trouble understanding what you want to accomplish.
On Wednesday, 10 October 2018 at 23:04:46 UTC, James Japherson
wrote:
It also has no context in and of itself. The compiler knows
what to do with it... The same
On Wednesday, 10 October 2018 at 13:32:15 UTC, Simen Kjærås wrote:
On Wednesday, 10 October 2018 at 08:46:42 UTC, James Japherson
wrote:
Would be nice to be able to pass $ as a function argument to
be used in automatic path length traversing.
void foo(int loc)
{
return bar[loc];
}
then
On 10/10/2018 01:46 AM, James Japherson wrote:
Would be nice to be able to pass $ as a function argument to be used in
automatic path length traversing.
$ only works in indexing operations because that's required to figure
out what it refers to. However, you can mostly use it as a readonly
On Wednesday, 10 October 2018 at 08:46:42 UTC, James Japherson
wrote:
Would be nice to be able to pass $ as a function argument to be
used in automatic path length traversing.
void foo(int loc)
{
return bar[loc];
}
then foo($) would essentilly become
foo(&)
becomes ==>
return
On Wednesday, 10 October 2018 at 08:46:42 UTC, James Japherson
wrote:
The usefulness comes from the case when bar is local:
void foo(int loc)
{
auto bar = double[RandomPInt+1];
return bar[loc];
}
then foo($) always returns a value and the outside world does
not need to know about
On Wednesday, 10 October 2018 at 08:46:42 UTC, James Japherson
wrote:
Would be nice to be able to pass $ as a function argument to be
used in automatic path length traversing.
void foo(int loc)
{
return bar[loc];
}
then foo($) would essentilly become
foo(&)
becomes ==>
return
Would be nice to be able to pass $ as a function argument to be
used in automatic path length traversing.
void foo(int loc)
{
return bar[loc];
}
then foo($) would essentilly become
foo(&)
becomes ==>
return bar[$];
instead of having do to thinks like foo(bar.length).
The
19 matches
Mail list logo