pass enough context to the opDollar? The nice
thing about opDollar is it's a simple mechanism. But as a simple
mechanism, it's hard to say how to give it enough context in this case.
In this specific case, you would need to know the index of the first
parameter. But what if the
On 10/2/20 9:32 AM, Steven Schveighoffer wrote:
This seems like an oversight. But it's not impossible.
Thank you Steve. Is there any chance that this mechanism will ever be
revised? Presumably it would require a DIP.
Just curry the information to the receiver. opDollar doesn'
On 10/1/20 10:34 PM, James Blachly wrote:
Suppose I have a data structure encoding sequence lengths:
seq1: 0 1 2 ... N
seq2: 0 1 2 3 4 ... M
seq3: 0 1 ... P
I would like to write opIndex and opDollar to support the notation
obj[seq, x .. $] to retrieve sequences.
However, given that
Suppose I have a data structure encoding sequence lengths:
seq1: 0 1 2 ... N
seq2: 0 1 2 3 4 ... M
seq3: 0 1 ... P
I would like to write opIndex and opDollar to support the notation
obj[seq, x .. $] to retrieve sequences.
However, given that opDollar is templated on dimension (always 1 in
On 09/29/2017 11:34 AM, Joseph wrote:
Trying to do multi-dimension array but op-dollar doesn't seem to support
arbitrary dimensions
@property int opDollar(size_t dim : k)() { return dims[k]; }
It's called by multi-dimensional opIndex (or opSlice and perhaps
others?; c
Trying to do multi-dimension array but op-dollar doesn't seem to
support arbitrary dimensions
@property int opDollar(size_t dim : k)() { return dims[k]; }
On 28/12/14 19:21, Tobias Pankrath via Digitalmars-d-learn wrote:
To allow slicing for types that don't have a length property but
are terminated by a sentinel value, like null terminated strings
or single linked lists.
It's usefull for multi-dimensional containers as well.
Ah, clear. Thanks
On Sun, 28 Dec 2014 19:02:59 +0100
Joseph Rushton Wakeling via Digitalmars-d-learn
wrote:
> A question that suddenly occurred to me, and I realized I didn't know the
> answer.
>
> Why is it necessary/desirable to define separate .length and .opDollar
> methods
> for
swer.
> >
> > Why is it necessary/desirable to define separate .length and
> > .opDollar methods for custom types?
>
> To allow slicing for types that don't have a length property but
> are terminated by a sentinel value, like null terminated strings
> or s
On Sunday, 28 December 2014 at 18:12:42 UTC, Joseph Rushton
Wakeling via Digitalmars-d-learn wrote:
A question that suddenly occurred to me, and I realized I
didn't know the answer.
Why is it necessary/desirable to define separate .length and
.opDollar methods for custom types?
To
A question that suddenly occurred to me, and I realized I didn't know the
answer.
Why is it necessary/desirable to define separate .length and .opDollar methods
for custom types?
On Saturday, December 29, 2012 23:15:34 Era Scarecrow wrote:
> Oh yes, dmd version 2.60, Windows 32bit version. I pretty sure
> it would propagate all versions.
That would be your problem. It's not fixed in 2.060. It was fixed since then.
Use the latest from git or the current beta.
- Jonathan
Oh yes, dmd version 2.60, Windows 32bit version. I pretty sure
it would propagate all versions.
Wasn't opDollar was fixed? Slices don't seem to be working... In
one of my tests (can't duplicate here for some reason) using
__dollar when it would see __dollar it complained about needing
'this' access.
struct S {
int[] x;
this(int[] x) {this.x = x;}
int op
so, what is the signature for opDollar() in a struct. I'm getting
errors trying to implement this.
That parameter means number of dimension. When implementing some kind of
multidimensional array (e.g. an 2D raster Image) you'd have:
img[$-1, $-1] = lastValue; // the first dollar should resolv
> Also, what is the signature for opDollar() in a struct. I'm getting
> errors trying to implement this.
I don't think that opDollar is actually implemented yet. See
http://d.puremagic.com/issues/show_bug.cgi?id=3474
- Jonathan M Davis
On 26.03.2011 11:03, Caligo wrote:
"In the expression a[, ...,], if $ occurs in, it is rewritten as a.opDollar!(i)()." -- TDPL, pg 380
Is that correct? if so, could some one give an example code? I don't
understand the need for the parameter.
Also, what is the signature for
"In the expression a[, ..., ], if $ occurs in , it is rewritten as a.opDollar!(i)()." -- TDPL, pg 380
Is that correct? if so, could some one give an example code? I don't
understand the need for the parameter.
Also, what is the signature for opDollar() in a struct. I'm g
I think this might have been reported:
http://d.puremagic.com/issues/show_bug.cgi?id=3474
On 12/12/10, spir wrote:
> Hello,
>
> Test case:
>
> struct S {
> int[] ints;
> int opDollar () {return this.ints.length;}
> int opIndex (int i) {return this.ints[i];}
Hello,
Test case:
struct S {
int[] ints;
int opDollar () {return this.ints.length;}
int opIndex (int i) {return this.ints[i];}
int[] opSlice (int i, int j) {return this.ints[i..j];}
}
unittest {
S s = S([3,2,1]);
// _link_ error on each line:
// Error: undefined
20 matches
Mail list logo