Wiki

Ticket #71 (closed defect: fixed)

Opened 15 years ago

Last modified 15 years ago

Cannot enumerate an int in a `for` expression

Reported by: Chuck Owned by: Chuck
Priority: medium Milestone:
Component: Cobra Compiler Version: 0.8.0
Keywords: Cc:

Description

for statements support both sequences and integers:

for cust in customers
    print cust
for i in 10
    print i, i*2

Then there is a for expression, but using it on integers causes an error:

custs = for cust in customers where cust.hasOutstandingBalance

# errors
nums = for i in 10 get i*2
objs = for i in j get items[i+1]

for expressions on integers are occasionally needed and would make the language more symmetrical.

Attachments

for-expr-numeric.patch Download (8.5 KB) - added by hopscc 15 years ago.

Change History

Changed 15 years ago by hopscc

Changed 15 years ago by hopscc

  • owner set to Chuck
  • status changed from new to assigned

Patch supporting single int and slice like int expression in for-expr same as in for-stmt. Test files for this and enumerable for-expr

Changed 15 years ago by Chuck

  • status changed from assigned to closed
  • resolution set to fixed

Fixed in changeset:1829

Thanks.

Note: See TracTickets for help on using tickets.