www.digitalmars.com         C & C++   DMDScript  

D - operator~

reply "Pavel Minayev" <evilone omen.ru> writes:
It looks a bit strange to me... for example, compare these
two lines of code:

    int[] a;
    ...
    a ~= 1;      // works
    a = a ~ 1;   // doesn't work!

Looks weird... why can't I concatenate an int array and a
single interger? Furthermore, I believe that the following
should work as well:

    a = 1 ~ a;
    a = 1 ~ 2;

Take a look at the latter - binary ~ should make an array
out of its operands if they aren't already arrays. This
could be a very useful operation, since it practically
replaces array literals:

    double max(double[] n) { ... }
    double a, b, c, d;
    ...
    d = max(a ~ b ~ c);

Using suffices, array of almost any built-in type can be
constructed:

      1 ~   2 ~   3        int[]
     1U ~  2U ~  3U        uint[]
     1L ~  2L ~  3L        long[]
    1UL ~ 2UL ~ 3UL        ulong[]
    1.0 ~ 2.0 ~ 3.0        double[]
    ...............................

Only byte and short don't have their suffices (BTW, why
not? "b" and "s" would suite just fine).

What do you think of this, Walter? Is it a good idea?
Mar 02 2002
next sibling parent reply "Walter" <walter digitalmars.com> writes:
It does sound like a logical extension. I'll add it in to the list! -Walter

"Pavel Minayev" <evilone omen.ru> wrote in message
news:a5qbcq$1kss$1 digitaldaemon.com...
 It looks a bit strange to me... for example, compare these
 two lines of code:

     int[] a;
     ...
     a ~= 1;      // works
     a = a ~ 1;   // doesn't work!

 Looks weird... why can't I concatenate an int array and a
 single interger? Furthermore, I believe that the following
 should work as well:

     a = 1 ~ a;
     a = 1 ~ 2;

 Take a look at the latter - binary ~ should make an array
 out of its operands if they aren't already arrays. This
 could be a very useful operation, since it practically
 replaces array literals:

     double max(double[] n) { ... }
     double a, b, c, d;
     ...
     d = max(a ~ b ~ c);

 Using suffices, array of almost any built-in type can be
 constructed:

       1 ~   2 ~   3        int[]
      1U ~  2U ~  3U        uint[]
      1L ~  2L ~  3L        long[]
     1UL ~ 2UL ~ 3UL        ulong[]
     1.0 ~ 2.0 ~ 3.0        double[]
     ...............................

 Only byte and short don't have their suffices (BTW, why
 not? "b" and "s" would suite just fine).

 What do you think of this, Walter? Is it a good idea?
Mar 02 2002
parent reply "Pavel Minayev" <evilone omen.ru> writes:
"Walter" <walter digitalmars.com> wrote in message
news:a5r2rl$1uiq$1 digitaldaemon.com...

 It does sound like a logical extension. I'll add it in to the
list! -Walter Great to hear that! By the way, with all those feature requests around... =) You've mentioned several times that some things will be implemented sooner or later, but probably won't get into version 1. Do you have any "feature list" of what gets there, then? Templates are out, I guess, what about operator overloading? In other words, what should we expect by DMD 1.0 release, whenever it happens?
Mar 02 2002
parent reply "Walter" <walter digitalmars.com> writes:
"Pavel Minayev" <evilone omen.ru> wrote in message
news:a5r4r7$1vic$1 digitaldaemon.com...
 "Walter" <walter digitalmars.com> wrote in message
 news:a5r2rl$1uiq$1 digitaldaemon.com...
 By the way, with all those feature requests around... =)
 You've mentioned several times that some things will be implemented
 sooner or later, but probably won't get into version 1. Do you
 have any "feature list" of what gets there, then? Templates are
 out, I guess, what about operator overloading? In other words, what
 should we expect by DMD 1.0 release, whenever it happens?
What's in the spec right now should be 1.0. -Walter
Mar 02 2002
parent reply "Pavel Minayev" <evilone omen.ru> writes:
"Walter" <walter digitalmars.com> wrote in message
news:a5rmmi$26rg$1 digitaldaemon.com...

 What's in the spec right now should be 1.0. -Walter
Any (probably approximate) release date? Or "when it's done"?
Mar 03 2002
parent "Walter" <walter digitalmars.com> writes:
"Pavel Minayev" <evilone omen.ru> wrote in message
news:a5u2l6$fll$1 digitaldaemon.com...
 "Walter" <walter digitalmars.com> wrote in message
 news:a5rmmi$26rg$1 digitaldaemon.com...
 What's in the spec right now should be 1.0. -Walter
Any (probably approximate) release date? Or "when it's done"?
The release date was 6 months ago <g>.
Mar 03 2002
prev sibling parent reply "Walter" <walter digitalmars.com> writes:
"Pavel Minayev" <evilone omen.ru> wrote in message
news:a5qbcq$1kss$1 digitaldaemon.com...
 Only byte and short don't have their suffices (BTW, why
 not? "b" and "s" would suite just fine).
Just realized "b" won't work, it's a hex digit. There goes consistency!
Mar 02 2002
parent "OddesE" <OddesE_XYZ hotmail.com> writes:
"Walter" <walter digitalmars.com> wrote in message
news:a5rr4o$28uv$1 digitaldaemon.com...
 "Pavel Minayev" <evilone omen.ru> wrote in message
 news:a5qbcq$1kss$1 digitaldaemon.com...
 Only byte and short don't have their suffices (BTW, why
 not? "b" and "s" would suite just fine).
Just realized "b" won't work, it's a hex digit. There goes consistency!
So bt then? Or by? -- Stijn OddesE_XYZ hotmail.com http://OddesE.cjb.net __________________________________________ Remove _XYZ from my address when replying by mail
Mar 02 2002