Mars Programming Language

Variables should not require declaration

Reported by Matt Giuca on 2009-11-15
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mars
High
Matt Giuca

Bug Description

Mars has always required variables declared with the "var" keyword.

This is annoying. Mars (like Python) should treat any variable assigned anywhere in the body of a function as local, and infer the type from the assignment statement. (This is already done in interactive mode, and for variables created in switch statements).

Related branches

Matt Giuca (mgiuca) on 2009-11-18
Changed in mars:
milestone: none → 0.3
Matt Giuca (mgiuca) on 2009-11-18
Changed in mars:
status: New → Triaged
Matt Giuca (mgiuca) wrote :

This should be fixed automatically by bug #513633. Since assignments would be treated as pattern bindings, the same declaration-free semantics of switch statements would be used by assignments. Therefore, it would not be necessary to declare variables at all in Mars.

HOWEVER, note the last paragraph of this bug report still holds -- need to fix the fact that if a local variable is bound by a pattern (assignment or switch), it can't be treated as a global beforehand, even if only being read.

Matt Giuca (mgiuca) wrote :

The second part of this bug, making sure that implicitly-declared locals are scoped to the whole function, is now a separate bug #513638.

Fix bug #513633 and bug #513638, and you should have full support for implicitly-declared variables.

Note that the "var" keyword should not be removed. I'd like to keep it around, so it is possible to *explicitly* declare a variable, if desired.

Matt Giuca (mgiuca) on 2010-04-28
description: updated
description: updated
Matt Giuca (mgiuca) wrote :

I no longer consider this to be "Blocked by bug #513633 and bug #513638." While allowing declaration-free variables will expose those two bugs, they are already exposed via pattern bindings. So I'll allow this (further exposing those two bugs) and fix them afterwards.

(In a branch -- newtypes.)

Now high priority.

Changed in mars:
importance: Wishlist → High
description: updated
Matt Giuca (mgiuca) wrote :

Fixed in newtypes branch, r1013.

Changed in mars:
status: Triaged → Fix Committed
Matt Giuca (mgiuca) wrote :

Merged to trunk, r1030.

Matt Giuca (mgiuca) on 2010-06-25
Changed in mars:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers