On Friday, 31 March 2023 at 02:23:29 UTC, Steven Schveighoffer
wrote:
There's a certain attempt in phobos in some places to try and
ensure code that is going to confuse will not compile. I think
this is one of those attempts.
Consider that if you pass a slice into `put`, then it returns
nothi
On 3/30/23 11:44 AM, Paul Backus wrote:
It should be fine to have both a `ref` and non-`ref` overload for `put`,
though, right? If the non-`ref` overload is only called with rvalues,
then it's fine to leave them in an undetermined state, because nothing
can access them afterward anyway.
Ther
On Thursday, 30 March 2023 at 13:27:33 UTC, Steven Schveighoffer
wrote:
But you can do `dig.copy(buf[])` since a dynamic array is.
Apparently, we will not be able to get rid of the necessity of
using slices. 😀 Neither with "copy" nor with "put"...
```d
import std.algorithm.mutation : copy;
On Wednesday, 29 March 2023 at 20:50:04 UTC, Steven Schveighoffer
wrote:
On 3/29/23 4:29 PM, ag0aep6g wrote:
But regardless of Salih's exact intent, the broader point is:
a non-ref overload could be added to Phobos. And that would
enable `a[1..$-1].phobos_put([2, 3])`. Which is what he asked
On 3/29/23 11:01 PM, Salih Dincer wrote:
```d
import std.algorithm.mutation : copy;
void main()
{
  int[8] buf;
  auto dig = [1, 2, 3, 4];
  auto rem = dig.copy(buf);
  assert(rem.length == 4);
}
```
Looks like 'copy' has the same overload issue.
A static array is not a range of any kind
On Wednesday, 29 March 2023 at 20:50:04 UTC, Steven Schveighoffer
wrote:
On 3/29/23 4:29 PM, ag0aep6g wrote:
But regardless of Salih's exact intent, the broader point is:
a non-ref overload could be added to Phobos. And that would
enable `a[1..$-1].phobos_put([2, 3])`. Which is what he asked
On 3/29/23 4:29 PM, ag0aep6g wrote:
But regardless of Salih's exact intent, the broader point is: a non-ref
overload could be added to Phobos. And that would enable
`a[1..$-1].phobos_put([2, 3])`. Which is what he asked about originally.
I think the idea of requiring ref output ranges is that
On Wednesday, 29 March 2023 at 20:29:24 UTC, ag0aep6g wrote:
But regardless of Salih's exact intent, the broader point is: a
non-ref overload could be added to Phobos. And that would
enable `a[1..$-1].phobos_put([2, 3])`. Which is what he asked
about originally.
Yes, that was it, but even mor
On Wednesday, 29 March 2023 at 19:49:47 UTC, Ali Çehreli wrote:
On 3/29/23 12:21, ag0aep6g wrote:
> As far as I understand, you're saying that we cannot overload
on `ref`.
> But we can. Salih's code demonstrates just that.
>
> void f(ref int x) {}
> void f(int x) {}
> void main() { int x; f(x);
On Wednesday, 29 March 2023 at 19:49:47 UTC, Ali Çehreli wrote:
I thought Salih was proposing two more overloads to the
existing put(). When I copy the existing put(), which takes
'ref R', not R[], then the code does not compile:
auto put(R)(R[] range, R[] source)
=> putImpl(range, source);
On 3/29/23 12:21, ag0aep6g wrote:
> As far as I understand, you're saying that we cannot overload on `ref`.
> But we can. Salih's code demonstrates just that.
>
> void f(ref int x) {}
> void f(int x) {}
> void main() { int x; f(x); f(42); } /* no errors */
I thought Salih was proposing two more
On Wednesday, 29 March 2023 at 16:44:31 UTC, Ali Çehreli wrote:
On 3/29/23 09:27, Salih Dincer wrote:
> In this way,
> it could also be used directly with slices. For example:
> auto put(R)(R[] range, R[] source)
>=> putImpl(range, source);
That's for rvalues.
> auto put(R)(ref R[] range,
On 3/29/23 09:27, Salih Dincer wrote:
> In this way,
> it could also be used directly with slices. For example:
> auto put(R)(R[] range, R[] source)
>=> putImpl(range, source);
That's for rvalues.
> auto put(R)(ref R[] range, R[] source)
>=> putImpl(range, source);
That's for lvalues.
On Wednesday, 29 March 2023 at 15:01:27 UTC, Ali Çehreli wrote:
On 3/29/23 04:48, Dennis wrote:
On the other hand, Phobos's put() works with any OutputRange so
it has to take a 'ref' to advance to know where it is left off.
This behavior makes its use with slices weird but sometimes
such is li
On 3/29/23 04:48, Dennis wrote:
> On Wednesday, 29 March 2023 at 11:10:42 UTC, Salih Dincer wrote:
>> Why does my `put` work but the Phobos `put` doesn't work with a slice?
>
> Your `put` doesn't take `range` by `ref`, so it allows you to pass an
> rvalue. Conseque
On Wednesday, 29 March 2023 at 11:10:42 UTC, Salih Dincer wrote:
Why does my `put` work but the Phobos `put` doesn't work with a
slice?
Your `put` doesn't take `range` by `ref`, so it allows you to
pass an rvalue. Consequently, it doesn't advance the range from
the callers perspective.
Why does my `put` work but the Phobos `put` doesn't work with a
slice?
onlineapp.d(11): Error: none of the overloads of template
`std.range.primitives.put` are callable using argument types
`!()(int[], int[])`
/dlang/dmd/linux/bin64/../../src/phobos/std/range/primitives.
Why does my `put` work but the Phobos `put` doesn't work with a
slice?
onlineapp.d(11): Error: none of the overloads of template
`std.range.primitives.put` are callable using argument types
`!()(int[], int[])`
/dlang/dmd/linux/bin64/../../src/phobos/std/range/primitives.
18 matches
Mail list logo