Attempted roadmap of future instance variables

Hi all,

I thought I’d weigh in here. Instead of relying on
per-variable syntax, what about a keyword? Here is
some fictional syntax.

class A
def foo
# regular instance variables
@var = “hi”

  # anything below 'local' here is a 
  # class-local instance variable
  local:
     var = "hello"

end

def bar
puts @var # ‘hi’
puts class.var # ‘hello’
end
end

Just an idea. Thoughts?

Regards,

Dan

···

Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.

Hi –

Hi all,

I thought I’d weigh in here. Instead of relying on
per-variable syntax, what about a keyword? Here is
some fictional syntax.

class A
def foo
# regular instance variables
@var = “hi”

  # anything below 'local' here is a 
  # class-local instance variable
  local:
     var = "hello"

end

def bar
puts @var # ‘hi’
puts class.var # ‘hello’
end
end

Just an idea. Thoughts?

I’m not sure where “class.var” comes from… var is an instance
variable of A objects, it looks like, not of A (unless you meant that
local: clause to come after the method definition?) and in any case
you haven’t defined a method called ‘var’, just a variable.

Also, how would you differentiate between the instance variable var
and a local variable (or method) called var?

(Mind you, my basic feeling about ‘local’ is that I would dislike it
:slight_smile: Nonetheless I’m curious how you would see it playing out.)

David

···

On Sat, 6 Dec 2003, Daniel Berger wrote:


David A. Black
dblack@wobblini.net