View previous topic :: View next topic |
Author |
Message |
vektorboson
Joined: 14 Sep 2006 Posts: 44
|
Posted: Mon Nov 09, 2009 5:08 pm Post subject: Array length? |
|
|
I've got a few questions/suggestions:
1. Am I blind, or is there no length-function for arrays?
2. Is there any syntax for table literals like: tbl = {"a":1, "b":2} ?
3. in minid/interpreter.d the maybeGC-function is declared returning void, but returns a uword in the function body.
I hope that you didn't give up completely on D! (Sometimes I'm in that mood, too!) |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
JarrettBillingsley
Joined: 20 Jun 2006 Posts: 457 Location: Pennsylvania!
|
Posted: Mon Nov 09, 2009 6:24 pm Post subject: |
|
|
1. Array, string, table, and namespace length are all handled by the unary length operator, #. "#x" will get you the length of x, no matter what it is (see here). You can also define the length operator for your own class instances by implementing the opLength metamethod (see here).
2. Yes, of course, I'm surprised you didn't see them in the examples See here.
3. You're right, that's a bug, thanks It's fixed, you can update your checkout. |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
vektorboson
Joined: 14 Sep 2006 Posts: 44
|
Posted: Tue Nov 10, 2009 4:06 am Post subject: |
|
|
@ 1. & 2.: double-facepalm!
I even looked at the arraylib implementation searching for the length-function, I must have been really blind yesterday!
Thanks a lot! |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
vektorboson
Joined: 14 Sep 2006 Posts: 44
|
Posted: Tue Nov 10, 2009 6:27 am Post subject: |
|
|
Me again, I have a problem with MiniD's formatting; the tango-docs say you can escape a curly brace by placing "{{".
Now MiniD expects a closing brace, thus I have to workaround like this:
format("... {} ...", "{")
if I want a single opening curly brace. |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
JarrettBillingsley
Joined: 20 Jun 2006 Posts: 457 Location: Pennsylvania!
|
Posted: Tue Nov 10, 2009 9:57 am Post subject: |
|
|
Gwah, another bug. Fixed ![Smile](images/smiles/icon_smile.gif) |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
|