FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Array length?

 
Post new topic   Reply to topic     Forum Index -> MiniD
View previous topic :: View next topic  
Author Message
vektorboson



Joined: 14 Sep 2006
Posts: 44

PostPosted: Mon Nov 09, 2009 5:08 pm    Post subject: Array length? Reply with quote

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
View user's profile Send private message
JarrettBillingsley



Joined: 20 Jun 2006
Posts: 457
Location: Pennsylvania!

PostPosted: Mon Nov 09, 2009 6:24 pm    Post subject: Reply with quote

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 Smile See here.

3. You're right, that's a bug, thanks Smile It's fixed, you can update your checkout.
Back to top
View user's profile Send private message
vektorboson



Joined: 14 Sep 2006
Posts: 44

PostPosted: Tue Nov 10, 2009 4:06 am    Post subject: Reply with quote

@ 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
View user's profile Send private message
vektorboson



Joined: 14 Sep 2006
Posts: 44

PostPosted: Tue Nov 10, 2009 6:27 am    Post subject: Reply with quote

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
View user's profile Send private message
JarrettBillingsley



Joined: 20 Jun 2006
Posts: 457
Location: Pennsylvania!

PostPosted: Tue Nov 10, 2009 9:57 am    Post subject: Reply with quote

Gwah, another bug. Fixed Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> MiniD All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group