Page 1 of 1

Things that bug me about Cobra Language.

PostPosted: Fri Sep 03, 2010 7:11 am
by hopscc
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

Re: Things that bug me about Cobra Language.

PostPosted: Fri Sep 03, 2010 9:49 am
by Charles
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)".

Re: Things that bug me about Cobra Language.

PostPosted: Wed Sep 15, 2010 5:33 am
by hopscc
Item raised as ticket:257.
patch/tests/etc for fix added.

for an alternative example perhaps
Code: Select all
.tryParse
??