digitalmars.D - Re: Biggest problems w/ D - strings
- C. Dunn (5/6) Aug 13 2007 Oh. Slices! I didn't think of that. It should be just as efficient too...
- Oskar Linde (4/7) Aug 13 2007 chars are initialized to 0xff
- Jarrett Billingsley (17/22) Aug 13 2007 There are a few ways to get that initialized to 0 in the struct, tho:
- Deewiant (5/26) Aug 13 2007 Ever since Issue 1268 was fixed in 1.017, you can just write:
- Jarrett Billingsley (3/5) Aug 14 2007 I always wished that that were possible, but never knew if it was legal ...
- Chris Nicholson-Sauls (15/25) Aug 14 2007 Oh it is, but there's no equivelant one-liner for dynamic arrays. Inste...
- Bill Baxter (4/36) Aug 14 2007 You gonna make that cashew available via dsss net any time soon? If not...
- Chris Nicholson-Sauls (5/43) Aug 14 2007 Well... I admit I don't actually use DSSS myself. (The shame, I know.)...
- Bill Baxter (11/57) Aug 14 2007 Well, I gave it a go, but cashew, seems to depend on mango. And "dsss
- kris (3/13) Aug 14 2007 fixed (thank you)
- Bill Baxter (5/19) Aug 14 2007 Did you check it in too? dsss net install mango still fails with the
- Chris Nicholson-Sauls (9/76) Aug 16 2007 Oh... my. (*dejected sigh*) No frets. The bits that are causing that ...
- Bill Baxter (39/115) Aug 16 2007 Sure. Well, currently my dsss.conf for cashew consists of exactly two
- Chris Nicholson-Sauls (9/65) Aug 16 2007 Ruby Gems also allows having multiple versions installed, although I've ...
- C. Dunn (2/9) Aug 14 2007 If I cannot tell the "new int[]" expression what the initializer should ...
Derek Parnell Wrote:You could try this simpler method ...Oh. Slices! I didn't think of that. It should be just as efficient too, since these slices will not copy the contents. As for your follow-up, I thought that char abc[32]; would initialize abc to 32 zeroes automatically. Am I wrong?
Aug 13 2007
C. Dunn wrote:As for your follow-up, I thought that char abc[32]; would initialize abc to 32 zeroes automatically. Am I wrong?chars are initialized to 0xff -- Oskar
Aug 13 2007
"Oskar Linde" <oskar.lindeREM OVEgmail.com> wrote in message news:f9qcug$2sgj$1 digitalmars.com...C. Dunn wrote:There are a few ways to get that initialized to 0 in the struct, tho: 1) Just write the initializer in the struct. struct S { char[32] abc = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]; } Kind of ugly, but straightforward. 2) Typedef a zero-init char type. typedef char zchar = 0; struct S { zchar[32] abc; } You then might run into annoyances when converting between char and zchar.As for your follow-up, I thought that char abc[32]; would initialize abc to 32 zeroes automatically. Am I wrong?chars are initialized to 0xff
Aug 13 2007
Jarrett Billingsley wrote:"Oskar Linde" <oskar.lindeREM OVEgmail.com> wrote in message news:f9qcug$2sgj$1 digitalmars.com...Ever since Issue 1268 was fixed in 1.017, you can just write: char[32] abc = 0; -- Remove ".doesnotlike.spam" from the mail address.C. Dunn wrote:There are a few ways to get that initialized to 0 in the struct, tho: 1) Just write the initializer in the struct. struct S { char[32] abc = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]; } Kind of ugly, but straightforward.As for your follow-up, I thought that char abc[32]; would initialize abc to 32 zeroes automatically. Am I wrong?chars are initialized to 0xff
Aug 13 2007
"Deewiant" <deewiant.doesnotlike.spam gmail.com> wrote in message news:f9rjbi$1sav$1 digitalmars.com...Ever since Issue 1268 was fixed in 1.017, you can just write: char[32] abc = 0;I always wished that that were possible, but never knew if it was legal :D
Aug 14 2007
Jarrett Billingsley wrote:"Deewiant" <deewiant.doesnotlike.spam gmail.com> wrote in message news:f9rjbi$1sav$1 digitalmars.com...Oh it is, but there's no equivelant one-liner for dynamic arrays. Instead you have to: auto var = new int[len]; var[] = 42; Or using Cashew: import cashew.utils.Array; // ... auto var = repeat(42, len); Which is actually just a wrapper around the above example. It'd be nice if there were some way to specify an initializor for a dynamic array's elements in place, that didn't rely on using a typedef. typedef int _MyInt42 = 42; auto var = cast(int[]) new _MyInt42[len]; o_O -- Chris Nicholson-SaulsEver since Issue 1268 was fixed in 1.017, you can just write: char[32] abc = 0;I always wished that that were possible, but never knew if it was legal :D
Aug 14 2007
Chris Nicholson-Sauls wrote:Jarrett Billingsley wrote:You gonna make that cashew available via dsss net any time soon? If not you mind if I do it? --bb"Deewiant" <deewiant.doesnotlike.spam gmail.com> wrote in message news:f9rjbi$1sav$1 digitalmars.com...Oh it is, but there's no equivelant one-liner for dynamic arrays. Instead you have to: auto var = new int[len]; var[] = 42; Or using Cashew: import cashew.utils.Array; // ... auto var = repeat(42, len); Which is actually just a wrapper around the above example. It'd be nice if there were some way to specify an initializor for a dynamic array's elements in place, that didn't rely on using a typedef. typedef int _MyInt42 = 42; auto var = cast(int[]) new _MyInt42[len]; o_OEver since Issue 1268 was fixed in 1.017, you can just write: char[32] abc = 0;I always wished that that were possible, but never knew if it was legal :D
Aug 14 2007
Bill Baxter wrote:Chris Nicholson-Sauls wrote:Well... I admit I don't actually use DSSS myself. (The shame, I know.) So if you want to do so, go ahead. I have a long list of to-do items for Cashew... should really get to work on it. (Like adding those nifty binutils.) -- Chris Nicholson-SaulsJarrett Billingsley wrote:You gonna make that cashew available via dsss net any time soon? If not you mind if I do it? --bb"Deewiant" <deewiant.doesnotlike.spam gmail.com> wrote in message news:f9rjbi$1sav$1 digitalmars.com...Oh it is, but there's no equivelant one-liner for dynamic arrays. Instead you have to: auto var = new int[len]; var[] = 42; Or using Cashew: import cashew.utils.Array; // ... auto var = repeat(42, len); Which is actually just a wrapper around the above example. It'd be nice if there were some way to specify an initializor for a dynamic array's elements in place, that didn't rely on using a typedef. typedef int _MyInt42 = 42; auto var = cast(int[]) new _MyInt42[len]; o_OEver since Issue 1268 was fixed in 1.017, you can just write: char[32] abc = 0;I always wished that that were possible, but never knew if it was legal :D
Aug 14 2007
Chris Nicholson-Sauls wrote:Bill Baxter wrote:Well, I gave it a go, but cashew, seems to depend on mango. And "dsss net install mango" is failing, so I guess I give up for now. Here's the error: mango\net\util\cache\model\ICache.d(15): module IMessage cannot read file 'mango\net\cluster\model\IMessage.d' ICache.d has this: private import mango.net.cluster.model.IMessage; but there is no mango/net/cluster directory in the sources that dsss net is grabbing. --bbChris Nicholson-Sauls wrote:Well... I admit I don't actually use DSSS myself. (The shame, I know.) So if you want to do so, go ahead. I have a long list of to-do items for Cashew... should really get to work on it. (Like adding those nifty binutils.) -- Chris Nicholson-SaulsJarrett Billingsley wrote:You gonna make that cashew available via dsss net any time soon? If not you mind if I do it? --bb"Deewiant" <deewiant.doesnotlike.spam gmail.com> wrote in message news:f9rjbi$1sav$1 digitalmars.com...Oh it is, but there's no equivelant one-liner for dynamic arrays. Instead you have to: auto var = new int[len]; var[] = 42; Or using Cashew: import cashew.utils.Array; // ... auto var = repeat(42, len); Which is actually just a wrapper around the above example. It'd be nice if there were some way to specify an initializor for a dynamic array's elements in place, that didn't rely on using a typedef. typedef int _MyInt42 = 42; auto var = cast(int[]) new _MyInt42[len]; o_OEver since Issue 1268 was fixed in 1.017, you can just write: char[32] abc = 0;I always wished that that were possible, but never knew if it was legal :D
Aug 14 2007
Bill Baxter wrote: [snip]Well, I gave it a go, but cashew, seems to depend on mango. And "dsss net install mango" is failing, so I guess I give up for now. Here's the error: mango\net\util\cache\model\ICache.d(15): module IMessage cannot read file 'mango\net\cluster\model\IMessage.d' ICache.d has this: private import mango.net.cluster.model.IMessage;fixed (thank you)
Aug 14 2007
kris wrote:Bill Baxter wrote: [snip]Did you check it in too? dsss net install mango still fails with the same error. Here's the svn url its using: svn export http://svn.dsource.org/projects/mango/trunk --bbWell, I gave it a go, but cashew, seems to depend on mango. And "dsss net install mango" is failing, so I guess I give up for now. Here's the error: mango\net\util\cache\model\ICache.d(15): module IMessage cannot read file 'mango\net\cluster\model\IMessage.d' ICache.d has this: private import mango.net.cluster.model.IMessage;fixed (thank you)
Aug 14 2007
Bill Baxter wrote:Chris Nicholson-Sauls wrote:Oh... my. (*dejected sigh*) No frets. The bits that are causing that problem are horridly out of date and mostly mildly incomplete. Much of Cashew will be getting re-written and/or updated soon. I'll let you know when the Mango dependencies have been cleaned out. A question: when requesting, for example, Tango from 'dsss net' does it grab the latest official release, or the current SVN snapshot? If the latter, I may just go ahead and try DSSS out and make Cashew ready myself. -- Chris Nicholson-SaulsBill Baxter wrote:Well, I gave it a go, but cashew, seems to depend on mango. And "dsss net install mango" is failing, so I guess I give up for now. Here's the error: mango\net\util\cache\model\ICache.d(15): module IMessage cannot read file 'mango\net\cluster\model\IMessage.d' ICache.d has this: private import mango.net.cluster.model.IMessage; but there is no mango/net/cluster directory in the sources that dsss net is grabbing. --bbChris Nicholson-Sauls wrote:Well... I admit I don't actually use DSSS myself. (The shame, I know.) So if you want to do so, go ahead. I have a long list of to-do items for Cashew... should really get to work on it. (Like adding those nifty binutils.) -- Chris Nicholson-SaulsJarrett Billingsley wrote:You gonna make that cashew available via dsss net any time soon? If not you mind if I do it? --bb"Deewiant" <deewiant.doesnotlike.spam gmail.com> wrote in message news:f9rjbi$1sav$1 digitalmars.com...Oh it is, but there's no equivelant one-liner for dynamic arrays. Instead you have to: auto var = new int[len]; var[] = 42; Or using Cashew: import cashew.utils.Array; // ... auto var = repeat(42, len); Which is actually just a wrapper around the above example. It'd be nice if there were some way to specify an initializor for a dynamic array's elements in place, that didn't rely on using a typedef. typedef int _MyInt42 = 42; auto var = cast(int[]) new _MyInt42[len]; o_OEver since Issue 1268 was fixed in 1.017, you can just write: char[32] abc = 0;I always wished that that were possible, but never knew if it was legal :D
Aug 16 2007
Chris Nicholson-Sauls wrote:Bill Baxter wrote:Sure. Well, currently my dsss.conf for cashew consists of exactly two lines: ---------dsss.conf--------- name = cashew [cashew] -------end dsss.conf------- And mango's is only slightly longer: ---------dsss.conf--------- name = mango [mango/icu] [mango/net] [mango/xml] ---------dsss.conf--------- If there are parts that are basically dead right now and shouldn't be included, then you can just add an 'exclude' line. I.e. if you just want to leave out the mango-depending parts just make it e.g.: ---------dsss.conf--------- name = cashew [cashew] exclude = cashew/utils/Benchmark.d -------end dsss.conf-------Chris Nicholson-Sauls wrote:Oh... my. (*dejected sigh*) No frets. The bits that are causing that problem are horridly out of date and mostly mildly incomplete. Much of Cashew will be getting re-written and/or updated soon. I'll let you know when the Mango dependencies have been cleaned out.Bill Baxter wrote:Well, I gave it a go, but cashew, seems to depend on mango. And "dsss net install mango" is failing, so I guess I give up for now. Here's the error: mango\net\util\cache\model\ICache.d(15): module IMessage cannot read file 'mango\net\cluster\model\IMessage.d' ICache.d has this: private import mango.net.cluster.model.IMessage; but there is no mango/net/cluster directory in the sources that dsss net is grabbing. --bbChris Nicholson-Sauls wrote:Well... I admit I don't actually use DSSS myself. (The shame, I know.) So if you want to do so, go ahead. I have a long list of to-do items for Cashew... should really get to work on it. (Like adding those nifty binutils.) -- Chris Nicholson-SaulsJarrett Billingsley wrote:You gonna make that cashew available via dsss net any time soon? If not you mind if I do it? --bb"Deewiant" <deewiant.doesnotlike.spam gmail.com> wrote in message news:f9rjbi$1sav$1 digitalmars.com...Oh it is, but there's no equivelant one-liner for dynamic arrays. Instead you have to: auto var = new int[len]; var[] = 42; Or using Cashew: import cashew.utils.Array; // ... auto var = repeat(42, len); Which is actually just a wrapper around the above example. It'd be nice if there were some way to specify an initializor for a dynamic array's elements in place, that didn't rely on using a typedef. typedef int _MyInt42 = 42; auto var = cast(int[]) new _MyInt42[len]; o_OEver since Issue 1268 was fixed in 1.017, you can just write: char[32] abc = 0;I always wished that that were possible, but never knew if it was legal :DA question: when requesting, for example, Tango from 'dsss net' does it grab the latest official release, or the current SVN snapshot? If the latter, I may just go ahead and try DSSS out and make Cashew ready myself.I _think_ it grabs it from the latest SVN. And then optionally applies a dsss compatibility patch to it. If so then it should be pretty trivial to change dsss to grab a particular branch/tag from svn instead of the default branch. Maybe it already has this capability? I do think DSSS is going to have to confront the versioning issue soon, though. There needs to be a way to ask for a specific version when using net install. And maybe even a way to install more than one version of the same package. The other package manager I'm familiar with (Python setuptools/eggs) handle both. Basically instead of installing package foo into the "foo" directory, it installs it into a directory like "foo-{fooversion}-{pythonversion}.egg/foo", and then adds "foo-{fooversion}-{pythonversion}.egg" to a file that lists the current include path. I think a similar scheme could work for dsss. It lets you have more than one version of a package installed, but the order in that that master list of includes determines globally which version is active. --bb
Aug 16 2007
Bill Baxter wrote:Chris Nicholson-Sauls wrote:[snip]Ruby Gems also allows having multiple versions installed, although I've never looked into the details of how it keeps them. Gem also has 'update' for generically grabbing new versions of installed packages, and 'cleanup' for likewise uninstalling old versions. If and when DSSS adds support for multiple installations, something like these two commands would be doubtless useful. I've used them, for example, to test whether or not a new version of a library breaks anything before I commit to updating it. -- Chris Nicholson-SaulsOh... my. (*dejected sigh*) No frets. The bits that are causing that problem are horridly out of date and mostly mildly incomplete. Much of Cashew will be getting re-written and/or updated soon. I'll let you know when the Mango dependencies have been cleaned out.Sure. Well, currently my dsss.conf for cashew consists of exactly two lines: ---------dsss.conf--------- name = cashew [cashew] -------end dsss.conf------- And mango's is only slightly longer: ---------dsss.conf--------- name = mango [mango/icu] [mango/net] [mango/xml] ---------dsss.conf--------- If there are parts that are basically dead right now and shouldn't be included, then you can just add an 'exclude' line. I.e. if you just want to leave out the mango-depending parts just make it e.g.: ---------dsss.conf--------- name = cashew [cashew] exclude = cashew/utils/Benchmark.d -------end dsss.conf-------A question: when requesting, for example, Tango from 'dsss net' does it grab the latest official release, or the current SVN snapshot? If the latter, I may just go ahead and try DSSS out and make Cashew ready myself.I _think_ it grabs it from the latest SVN. And then optionally applies a dsss compatibility patch to it. If so then it should be pretty trivial to change dsss to grab a particular branch/tag from svn instead of the default branch. Maybe it already has this capability? I do think DSSS is going to have to confront the versioning issue soon, though. There needs to be a way to ask for a specific version when using net install. And maybe even a way to install more than one version of the same package. The other package manager I'm familiar with (Python setuptools/eggs) handle both. Basically instead of installing package foo into the "foo" directory, it installs it into a directory like "foo-{fooversion}-{pythonversion}.egg/foo", and then adds "foo-{fooversion}-{pythonversion}.egg" to a file that lists the current include path. I think a similar scheme could work for dsss. It lets you have more than one version of a package installed, but the order in that that master list of includes determines globally which version is active.
Aug 16 2007
Chris Nicholson-Sauls Wrote:If I cannot tell the "new int[]" expression what the initializer should be, then I would rather it not initialize at all. In the case above, it initializes twice!Oh it is, but there's no equivelant one-liner for dynamic arrays. Instead you have to: auto var = new int[len]; var[] = 42;Ever since Issue 1268 was fixed in 1.017, you can just write: char[32] abc = 0;I always wished that that were possible, but never knew if it was legal :D
Aug 14 2007