[no need to change]Variable names error in class define

Report problems with documented functionality
User avatar
RobertL
Posts: 546
Joined: 18 Jan 2014, 01:14
Location: China

[no need to change]Variable names error in class define

07 Jul 2014, 07:09

Code: Select all

class c{
	■:=1	;Expected assignment or class/method definition. only in V1.
			;Perhaps it should be "Invalid class variable declaration." (which occur when variable name "/a")
	a■:=2	;Same error
}
■:=3	;fine
a■:=4	;fine
I think the rule of variable name are the same as class variable as normal variable.
Last edited by RobertL on 08 Jul 2014, 23:03, edited 1 time in total.
我为人人,人人为己?
lexikos
Posts: 9621
Joined: 30 Sep 2013, 04:07
Contact:

Re: Variable names error in class define

07 Jul 2014, 23:25

I think the rule of variable name are the same as class variable as normal variable.
No; class variable names must be alphanumeric/underscore in v1.

A class variable declaration begins with a valid class variable name. Since there isn't one, it isn't recognized. I see no need to change this.
"Invalid class variable declaration." (which occur when variable name "/a")
That only occurs for the static keyword, followed by a space or tab, but then not followed by a valid variable declaration. It has nothing to do with the name.

Code: Select all

class c{
    /a := 1   ; This becomes a continuation of the previous line due to the /.
}
/*
Error: Missing "{"
     Specifically: c{ /a := 1
User avatar
RobertL
Posts: 546
Joined: 18 Jan 2014, 01:14
Location: China

Re: Variable names error in class define

08 Jul 2014, 07:55

Exception about "Invalid class variable declaration.": (just point out, I'm not suffer it )

Code: Select all

class c{
	a:=1,
	/b:=1	;Invalid class variable declaration.
}
Thx. I didn't notice this, the contents of specifically information are on the same line, for continuation.

Code: Select all

Specifically: c{ /a := 1
This question is relative about this...
I want to use class as normal object, with normal key name (like normal variable) and simulate for namespace.
Please see this post, I don't find a good way from their discuss.
我为人人,人人为己?
lexikos
Posts: 9621
Joined: 30 Sep 2013, 04:07
Contact:

Re: Variable names error in class define

08 Jul 2014, 16:26

Exception about "Invalid class variable declaration.":
Ah yes, in this case the "line" begins with a:=1,. If you hadn't put the comma at the end, you would not have got an error message. It would have been equivalent to this:

Code: Select all

a:=1/b:=2   ; b is a global var in this case, and a receives the value 0.5 (1/2).

Return to “Bug Reports”

Who is online

Users browsing this forum: Cicin and 17 guests