January 03, 2002 Re: New Operator Idea: *== (array value comparison operator) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean L. Palmer | "Sean L. Palmer" wrote: > It'd be really handy to be able to decorate an existing class with extra (non-virtual) member functions. Access would probably be restricted to public interface. Good idea! It might not sit well with all of the OOP purists, but very practical! -- The Villagers are Online! villagersonline.com .[ (the fox.(quick,brown)) jumped.over(the dog.lazy) ] .[ (a version.of(English).(precise.more)) is(possible) ] ?[ you want.to(help(develop(it))) ] |
January 07, 2002 Re: New Operator Idea: *== (array value comparison operator) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Russ Lewis | "Russ Lewis" <spamhole-2001-07-16@deming-os.org> ha scritto nel messaggio news:3C34B440.C88029A8@deming-os.org... > "Sean L. Palmer" wrote: > > > It'd be really handy to be able to decorate an existing class with extra (non-virtual) member functions. Access would probably be restricted to public interface. > > Good idea! It might not sit well with all of the OOP purists, but very practical! I like it in the form of static faunctions. For example I like the Java way of declaring static functions in classes: double base = Math.tan(x); // angle tangent double base = Finance.tan(x, y, z); // annual rate So you'll see: if (String.cat(a, b) == c) ... instead of: if (strct(a, b) = c) ... I know, I'm prolix. Ciao |
January 07, 2002 Re: New Operator Idea: *== (array value comparison operator) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Roberto Mariottini | "Roberto Mariottini" <rmariottini@lycosmail.com> wrote in message news:a1c86m$131n$1@digitaldaemon.com... > I like it in the form of static faunctions. For example I like the Java way > of declaring > static functions in classes: > > double base = Math.tan(x); // angle tangent > double base = Finance.tan(x, y, z); // annual rate > > So you'll see: > > if (String.cat(a, b) == c) ... > > instead of: > > if (strct(a, b) = c) ... > > I know, I'm prolix. D offers an alternative of modules. Just write a "string" module (in fact, it's already there =)), and call it in the same way: if (string.cmp(a, b) == c) ... But for us C freaks, simple cmp() without any strings is there =) |
January 07, 2002 Re: New Operator Idea: *== (array value comparison operator) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel Minayev | Oh, btw... so what about string (array) comparison op? |
January 07, 2002 Re: New Operator Idea: *== (array value comparison operator) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Russ Lewis | "Russ Lewis" <spamhole-2001-07-16@deming-os.org> ha scritto nel messaggio news:3C281D5C.1E8E1C1B@deming-os.org... > I've been thinking of how we could easily (with an operator) compare > strings. > > As Walter pointed out, == is problematic because you might want to compare the address of the arrays or you might want to compare the values in them. This reminds me of my college times, when using Simula there were two assignment operators: one to assign the object reference, and one to copy the object value(s). int a[]; int b[]; a = ... something ... b = a; // the reference or the value? b = ... something ... // change b only or both a and b? The same problem here arise for comparisions: if (a == b) // the reference or the value? If there where two assignement and comparison operators: Foo a; Foo b; a = b; // assign the reference a := b; // copy the value if (a == b) // they are the same object if (a :== b) // the have equivalent value This would be a BIG change in the language. P.S: please, don't use ~ for anything. In international keyboards there is no '~'. I have to press Alt-126 to get this weird char! Ciao |
January 07, 2002 Re: New Operator Idea: *== (array value comparison operator) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Roberto Mariottini | "Roberto Mariottini" <rmariottini@lycosmail.com> wrote in message news:a1c8m7$13dj$1@digitaldaemon.com... > If there where two assignement and comparison operators: This would be a BIG change in the language. Let's start a petition? =) > P.S: please, don't use ~ for anything. In international keyboards there is > no '~'. I have > to press Alt-126 to get this weird char! Hmmm... there is ~ on my Russian keyboard. Also, unary ~ is already used in C and C++ (and thus, in D). |
January 07, 2002 Re: New Operator Idea: *== (array value comparison operator) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel Minayev | "Pavel Minayev" <evilone@omen.ru> ha scritto nel messaggio news:a1cajj$14q1$1@digitaldaemon.com... > "Roberto Mariottini" <rmariottini@lycosmail.com> wrote in message news:a1c8m7$13dj$1@digitaldaemon.com... > > > If there where two assignement and comparison operators: This would be a BIG change in the language. > > Let's start a petition? =) > > > P.S: please, don't use ~ for anything. In international keyboards there is > > no '~'. I have > > to press Alt-126 to get this weird char! > > Hmmm... there is ~ on my Russian keyboard. Also, unary ~ > is already used in C and C++ (and thus, in D). Yes, but it's rarely used. Unary bit not is an operation that you'll use less frequently than string comparison. In italian keyboards, there are no {}~. But while braces can be achieved with the undocumented Shift-AltGr-[] combination under Windows, ~ can be achieved only with Alt-126. :-( Ciao. |
January 07, 2002 Re: New Operator Idea: *== (array value comparison operator) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Roberto Mariottini | "Roberto Mariottini" <rmariottini@lycosmail.com> wrote in message news:a1cj89$1a1u$1@digitaldaemon.com... > Yes, but it's rarely used. Unary bit not is an operation that you'll use > less > frequently than string comparison. ~ is also used for array concatenation already. |
January 09, 2002 Re: New Operator Idea: *== (array value comparison operator) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Roberto Mariottini | I don't understand yet the difference between '~' and '!'. If they have same meaning, why not remove '~' from D spec ? The concatenation could use another symbol. There are no tradition on '~=' . [s] "Roberto Mariottini" <rmariottini@lycosmail.com> wrote in message news:a1cj89$1a1u$1@digitaldaemon.com... "Pavel Minayev" <evilone@omen.ru> ha scritto nel messaggio news:a1cajj$14q1$1@digitaldaemon.com... > "Roberto Mariottini" <rmariottini@lycosmail.com> wrote in message news:a1c8m7$13dj$1@digitaldaemon.com... > > > If there where two assignement and comparison operators: This would be a BIG change in the language. > > Let's start a petition? =) > > > P.S: please, don't use ~ for anything. In international keyboards there is > > no '~'. I have > > to press Alt-126 to get this weird char! > > Hmmm... there is ~ on my Russian keyboard. Also, unary ~ > is already used in C and C++ (and thus, in D). Yes, but it's rarely used. Unary bit not is an operation that you'll use less frequently than string comparison. In italian keyboards, there are no {}~. But while braces can be achieved with the undocumented Shift-AltGr-[] combination under Windows, ~ can be achieved only with Alt-126. :-( Ciao. |
January 09, 2002 Re: New Operator Idea: *== (array value comparison operator) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Juarez Rudsatz | "Juarez Rudsatz" <juarez@correio.com> wrote in message news:a1ho6p$1erl$1@digitaldaemon.com... > I don't understand yet the difference between '~' and '!'. uint a = 1; ~a == 0b11111111111111111111111111111110; !a == 0; > The concatenation could use another symbol. There are no tradition on '~=' . Concatenation is already defined by ~. Large amount of code has already being written using this style. Also, Walter seems to like his invention - personally, me too, now - and won't give up so easy. =) We tried to convince him to change it already once, but... well you can see the results =) |
Copyright © 1999-2021 by the D Language Foundation