digitalmars.D.learn - String Basics
- Heinz (4/4) Jun 23 2006 Hi, it's a kind of silly question: How can i use a string as a type? for...
- Frank Benoit (3/3) Jun 23 2006 In D there is no "string". Instead there is char[] (, dchar[] or wchar[]...
- Yossarian (4/11) Jun 24 2006 try to write somewhere in declaration part:
- David Medlock (4/17) Jun 24 2006 or get Walter to put this in phobos!
- Heinz (5/9) Jun 24 2006 Thanks guys for your answers. I know it is a basic stuff, i used to work...
- Jarrett Billingsley (5/11) Jun 24 2006 D is "managed" ;) That's just MS's fancy term for "Garbage Collected."
- Jarrett Billingsley (4/5) Jun 24 2006 Though it might mean more. I've only ever heard it in the context of be...
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (5/6) Jun 25 2006 Managed means virtual machine. http://en.wikipedia.org/wiki/Managed_code
-
Andrei Khropov
(2/3)
Jun 25 2006
Well, what about D++ then?
- James Pelcis (3/8) Jun 25 2006 That's already taken.
- Stewart Gordon (10/15) Jun 26 2006 http://www.digitalmars.com/d/builtin.html
- Kent Boogaart (26/41) Jul 22 2006 I'm a late entrant on this discussion, but I've only just gotten on the ...
- Mike Parker (12/24) Jul 22 2006 You can do that now:
-
Stewart Gordon
(21/24)
Jul 23 2006
Hi, it's a kind of silly question: How can i use a string as a type? for example i want to pass a parameter as a string but the compiler says string is not defined, which module dhould i import to work with strings? thx.
Jun 23 2006
In D there is no "string". Instead there is char[] (, dchar[] or wchar[]). There are some utility functions in std.string, but for making use of char[] you need nothing to be imported.
Jun 23 2006
Heinz napsal(a):Hi, it's a kind of silly question: How can i use a string as a type? for example i want to pass a parameter as a string but the compiler says string is not defined, which module dhould i import to work with strings? thx.try to write somewhere in declaration part: alias char[] string; or use char[] as string:)
Jun 24 2006
Yossarian wrote:Heinz napsal(a):or get Walter to put this in phobos! :D -DavidMHi, it's a kind of silly question: How can i use a string as a type? for example i want to pass a parameter as a string but the compiler says string is not defined, which module dhould i import to work with strings? thx.try to write somewhere in declaration part: alias char[] string;
Jun 24 2006
In article <e7imaq$2jql$1 digitaldaemon.com>, Heinz says...Hi, it's a kind of silly question: How can i use a string as a type? for example i want to pass a parameter as a string but the compiler says string is not defined, which module dhould i import to work with strings? thx.Thanks guys for your answers. I know it is a basic stuff, i used to work with char[] in lower level languages but now i was used to the string type in managed languages. I'll use an alias for now but hope Walter to add a string type in phobos.
Jun 24 2006
"Heinz" <Heinz_member pathlink.com> wrote in message news:e7jj7v$sdo$1 digitaldaemon.com...Thanks guys for your answers. I know it is a basic stuff, i used to work with char[] in lower level languages but now i was used to the string type in managed languages.D is "managed" ;) That's just MS's fancy term for "Garbage Collected."I'll use an alias for now but hope Walter to add a string type in phobos.You'd be surprised, but char[] handles just about any kind of string handling. I've never felt like I was lacking an explicit string type in D.
Jun 24 2006
"Jarrett Billingsley" <kb3ctd2 yahoo.com> wrote in message news:e7kplh$2h7u$1 digitaldaemon.com...That's just MS's fancy term for "Garbage Collected."Though it might mean more. I've only ever heard it in the context of being "garbage collected."
Jun 24 2006
Jarrett Billingsley wrote:D is "managed" ;) That's just MS's fancy term for "Garbage Collected."Managed means virtual machine. http://en.wikipedia.org/wiki/Managed_code The usual / native code is now (belittlingly) known as Unmanaged code... --anders
Jun 25 2006
Anders F Björklund wrote:Well, what about D++ then? <g>
Jun 25 2006
Andrei Khropov wrote:Anders F Björklund wrote:That's already taken. http://www.pagemac.com/dpp/Well, what about D++ then? <g>
Jun 25 2006
Heinz wrote: <snip>Thanks guys for your answers. I know it is a basic stuff, i used to work with char[] in lower level languages but now i was used to the string type in managed languages. I'll use an alias for now but hope Walter to add a string type in phobos.http://www.digitalmars.com/d/builtin.html "But after all, what is a string if not an array of characters? If the builtin array problems are fixed, doesn't that resolve the string problems as well? It does. It seems odd at first that D doesn't have a string class, but since manipulating strings is nothing more than manipulating arrays of characters, if arrays work, there's nothing a class adds to it." Stewart.
Jun 26 2006
I'm a late entrant on this discussion, but I've only just gotten on the D band wagon . . . I think adding a string type has some serious merit. Namely: 1. "string" is a lot easier on the eyes than "char[]", to me at least. Especially when being used in an associative array: int[char[]] arr; versus int[string] arr; 2. string-specific functions can be added to the string type. I'm a complete D noob so forgive any misinformation here. Currently I understand there to be a separate module for string-related functions. To me, there should be a string type that defines those functions: char[] upper = toupper(myString); versus: string upper = myString.toupper(); The latter seems like much better OO design to me. Side note: I don't understand the namng of "toupper" as opposed to "toUpper" - isn't camel-casing the norm in D? Now arguably developers could just typedef or alias char[] as string and be done with it. But this doesn't address my second point. Or they could develop their own string class and be done with it. But this means that almost every decent-sized D project will have its own string implementation. Obviously not good. Regards, Kent Boogaart In article <e7oki3$2pfe$1 digitaldaemon.com>, Stewart Gordon says...Heinz wrote: <snip>Thanks guys for your answers. I know it is a basic stuff, i used to work with char[] in lower level languages but now i was used to the string type in managed languages. I'll use an alias for now but hope Walter to add a string type in phobos.http://www.digitalmars.com/d/builtin.html "But after all, what is a string if not an array of characters? If the builtin array problems are fixed, doesn't that resolve the string problems as well? It does. It seems odd at first that D doesn't have a string class, but since manipulating strings is nothing more than manipulating arrays of characters, if arrays work, there's nothing a class adds to it." Stewart.
Jul 22 2006
Kent Boogaart wrote:2. string-specific functions can be added to the string type. I'm a complete D noob so forgive any misinformation here. Currently I understand there to be a separate module for string-related functions. To me, there should be a string type that defines those functions: char[] upper = toupper(myString); versus: string upper = myString.toupper();You can do that now: char[] myString = "myString"; cahr[] upper = myString.toupper();The latter seems like much better OO design to me.Don't forget that D supports the procedural programming paradigm as well. Object Orientation has benefits, but is not a panacea. In my opinion, it shouldn't matter whether or not standard library APIs use OO design priniciples, as it generally does not affect the design of user code. Besides which, OO does not necessarily mean 'classes'. There are plenty of free function APIs that follow the OO paradigm. OpenGL is a great example. IMO, the need for a string class in D is imaginary. I have no use for one.
Jul 22 2006
Kent Boogaart wrote: <snip>Or they could develop their own string class and be done with it. But this means that almost every decent-sized D project will have its own string implementation. Obviously not good.<snip top of upside-down reply> Only if nearly every D programmer is an OO purist. http://www.digitalmars.com/d/overview.html "Who D is Not For" "Language purists. D is a practical language, and each feature of it is evaluated in that light, rather than by an ideal. For example, D has constructs and semantics that virtually eliminate the need for pointers for ordinary tasks. But pointers are still there, because sometimes the rules need to be broken. Similarly, casts are still there for those times when the typing system needs to be overridden." Stewart. -- -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCS/M d- s:- C++ a->--- UB P+ L E W++ N+++ o K- w++ O? M V? PS- PE- Y? PGP- t- 5? X? R b DI? D G e++++ h-- r-- !y ------END GEEK CODE BLOCK------ My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
Jul 23 2006