Forums

Things that bug me about Cobra Language.

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

Things that bug me about Cobra Language.

Postby hopscc » Fri Sep 03, 2010 7:11 am

Just to start a new discussion topic I'd appreciate any postings from anyone regarding things that bug/annoy/are seen as deficient in the current cobra language.
I'm not after new features specifically (though thats useful) or implementation/bug issues but more things that the language could do better or things that it should do that it currently doesnt...

To start the ball rolling heres one from me:

Cobra does local variable creation (and type inference) on first assignment. It annoys me that it doesnt do the same thing on first use of an out Param variable.
If you dont explicitly prior declare the Param variable you get a compile error.

Currently (as a for instance) you must do something like
Code: Select all
result as String?
if dict.tryGetValue(key, out result)
    print result

rather than just
Code: Select all
if dict.tryGetValue(key, out result)
    print result
# If the lookup returned the value and a success code it would just work via creation on assignment feature
ok, result = dict.tryGetValue(key)
if  ok, print result
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Re: Things that bug me about Cobra Language.

Postby Charles » Fri Sep 03, 2010 9:49 am

I think people have already been doing this, but with specific subjects like nevdelap's "== and equals()" message (which is now fixed).

I'm not sure what I think of being able to declare a var with "out". I'll mull it over.

On the subject of "out", I have wanted to be able to get the values via assignment like so:
did, value = dict.tryGetValue(key)

But this doesn't come up often enough that it has ever been high on my list.

Also, the .tryGetValue method itself is not a good example for me because nine times out of ten, I will simply use "dict.get(key, default)".
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Things that bug me about Cobra Language.

Postby hopscc » Wed Sep 15, 2010 5:33 am

Item raised as ticket:257.
patch/tests/etc for fix added.

for an alternative example perhaps
Code: Select all
.tryParse
??
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand


Return to Discussion

Who is online

Users browsing this forum: No registered users and 51 guests