Thread overview | ||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
March 08, 2002 String comparison == | ||||
---|---|---|---|---|
| ||||
The D HTML page on arrays mentions: ----------- Strings can be copied, compared, concatenated, and appended: if (str1 < str3) ... ----------- When I see "compared", I would take that to mean you could compare for content equality using the "==" operator - but that doesn't seem to be the case, and D seems to just do C-style pointer comparisons. Is string-content comparison using == just something that hasn't been implemented yet? or are the docs a bit misleading and string.cmp() is how it's going to have to be done? Barry |
March 08, 2002 Re: String comparison == | ||||
---|---|---|---|---|
| ||||
Posted in reply to Barry Pederson | "Barry Pederson" <barryp@yahoo.com> wrote in message news:3C883E19.3030407@yahoo.com... > When I see "compared", I would take that to mean you could compare for content > equality using the "==" operator - but that doesn't seem to be the case, and D > seems to just do C-style pointer comparisons. This is the topic raised several times, and I remember we've got to the idea that some separate operator to compare arrays is needed (because strings are just char arrays). Walter keeps silent on the topic, though, so the question is still open. |
March 08, 2002 Re: String comparison == | ||||
---|---|---|---|---|
| ||||
Posted in reply to Barry Pederson | "Barry Pederson" <barryp@yahoo.com> wrote in message news:3C883E19.3030407@yahoo.com... > The D HTML page on arrays mentions: > > ----------- > Strings can be copied, compared, concatenated, and appended: > > if (str1 < str3) ... > ----------- > > When I see "compared", I would take that to mean you could compare for content > equality using the "==" operator - but that doesn't seem to be the case, and D > seems to just do C-style pointer comparisons. > > Is string-content comparison using == just something that hasn't been implemented yet? or are the docs a bit misleading and string.cmp() is how it's going to have to be done? The issue is confusing, and it's a bit up in the air at the moment. |
March 08, 2002 Re: String comparison == | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | "Walter" <walter@digitalmars.com> schrieb im Newsbeitrag news:a69s6c$m38$1@digitaldaemon.com... > > "Barry Pederson" <barryp@yahoo.com> wrote in message news:3C883E19.3030407@yahoo.com... > > The D HTML page on arrays mentions: > > > > ----------- > > Strings can be copied, compared, concatenated, and appended: > > > > if (str1 < str3) ... > > ----------- > > > > When I see "compared", I would take that to mean you could compare for > content > > equality using the "==" operator - but that doesn't seem to be the case, > and D > > seems to just do C-style pointer comparisons. > > > > Is string-content comparison using == just something that hasn't been implemented yet? or are the docs a bit misleading and string.cmp() is how > > it's going to have to be done? > > The issue is confusing, and it's a bit up in the air at the moment. If I remember right, in Perl the operator "eq" is used.. what about that? Imi |
March 08, 2002 Re: String comparison == | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | "Walter" <walter@digitalmars.com> wrote in message news:a69s6c$m38$1@digitaldaemon.com... > > "Barry Pederson" <barryp@yahoo.com> wrote in message news:3C883E19.3030407@yahoo.com... > > The D HTML page on arrays mentions: > > > > ----------- > > Strings can be copied, compared, concatenated, and appended: > > > > if (str1 < str3) ... > > ----------- > > > > When I see "compared", I would take that to mean you could compare for > content > > equality using the "==" operator - but that doesn't seem to be the case, > and D > > seems to just do C-style pointer comparisons. > > > > Is string-content comparison using == just something that hasn't been implemented yet? or are the docs a bit misleading and string.cmp() is how > > it's going to have to be done? > > The issue is confusing, and it's a bit up in the air at the moment. I might suggest that this is a good reason for having "string" be a separate data type from "char[]". -- Richard Krehbiel, Arlington, VA, USA rich@kastle.com (work) or krehbiel3@comcast.net (personal) |
March 08, 2002 Re: String comparison == | ||||
---|---|---|---|---|
| ||||
Posted in reply to Immanuel Scholz | "Immanuel Scholz" <digitals-mars@kutzsche.net> wrote in message news:a6antm$10nh$1@digitaldaemon.com... > If I remember right, in Perl the operator "eq" is used.. what about that? I always hated it. Too hard to distinguish from name of local variable in a typical D program, anyhow. I believe it should be some sequence of special symbols rather than keyword. I suggested ~~ and !~ a while ago, but these aren't ideal because they are missing on some national keyboards. Maybe === and !== then? Lengthy, but I personally could leave with it... |
March 08, 2002 Re: String comparison == | ||||
---|---|---|---|---|
| ||||
Posted in reply to Richard Krehbiel | "Richard Krehbiel" <rich@kastle.com> wrote in message news:a6aos4$118b$1@digitaldaemon.com... > I might suggest that this is a good reason for having "string" be a separate > data type from "char[]". This has been discussed, and apart from the ability to define operator+ for concatenation, and operators == != < > <= >= for string comparison, it doesn't give any other opportunities. |
March 08, 2002 Re: String comparison == | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel Minayev | "Pavel Minayev" <evilone@omen.ru> wrote in message news:a6apl9$11fn$1@digitaldaemon.com... > "Richard Krehbiel" <rich@kastle.com> wrote in message news:a6aos4$118b$1@digitaldaemon.com... > > > I might suggest that this is a good reason for having "string" be a > separate > > data type from "char[]". > > This has been discussed, and apart from the ability to define operator+ for concatenation, and operators == != < > <= >= for string comparison, it doesn't give any other opportunities. You say that as if those things are inconsequential. I think they're not. Well, operator + might be. -- Richard Krehbiel, Arlington, VA, USA rich@kastle.com (work) or krehbiel3@comcast.net (personal) |
March 08, 2002 Re: String comparison == | ||||
---|---|---|---|---|
| ||||
Posted in reply to Richard Krehbiel | "Richard Krehbiel" <rich@kastle.com> wrote in message news:a6av8p$140b$1@digitaldaemon.com... > You say that as if those things are inconsequential. I think they're not. Well, operator + might be. I'm pretty happy with operator~ now. If Walter also gives us array equality/non-equality operator, I'll be completely satisfied. |
March 08, 2002 Re: String comparison == | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel Minayev | Pavel Minayev wrote: > "Richard Krehbiel" <rich@kastle.com> wrote in message news:a6aos4$118b$1@digitaldaemon.com... > > > I might suggest that this is a good reason for having "string" be a > separate > > data type from "char[]". > > This has been discussed, and apart from the ability to define operator+ for concatenation, and operators == != < > <= >= for string comparison, it doesn't give any other opportunities. Indeed, and I think that NOT having a separate type GIVES us new opportunities. Eventually, we will agree on some sort of syntax that makes sense. But since char[] is not a unique type with unique rules, this syntax will be able to be used on ALL arrays...perhaps even multidimensional arrays, if we are careful with how we choose the syntax. -- 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))) ] |
Copyright © 1999-2021 by the D Language Foundation