You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The declaration should be trivial, we probably don't even need local_variable for that, just make def int check it's argument. As for tracking the variable, at first look it seems impossible.. Without doing source inspection, I can't even think of a way to infer the name of the instance variable from def int
But checking at declare time is probably good enough.
Can you do String str; in Java? I know you can do public String str; in a class to declare members without assigning a value, so you can probably do that in local scope too?
@chancancode Thank for adding me to the repo! I'm honored.
I agree with you. It may be impossible or need dirty hack.
Anyway I start to implement defining method with checking it's argument. After that, I think about declare a variable.
Can you do String str; in Java? I know you can do public String str; in a class to declare members without assigning a value, so you can probably do that in local scope too?
oh, you'er totally right. sorry it's my mistake ; (
Sorry if it wasn't clear (I was typing on my phone), the last point was more of a question. I just checked and answered my own question, you can indeed do all of these in Java:
Stringa = "abc";
Stringb;
intc = 1;
intd;
I suppose String b and int d would just be no-ops in the gem, but it would be quite tricky to get that work unless you method_missing everything and return :variable_declaration or something like that...
Activity
gogotanaka commentedon Dec 3, 2014
How do we freeze variable itself or check type at every reassigning?
chancancode commentedon Dec 3, 2014
The declaration should be trivial, we probably don't even need local_variable for that, just make def int check it's argument. As for tracking the variable, at first look it seems impossible.. Without doing source inspection, I can't even think of a way to infer the name of the instance variable from def int
But checking at declare time is probably good enough.
Can you do String str; in Java? I know you can do public String str; in a class to declare members without assigning a value, so you can probably do that in local scope too?
gogotanaka commentedon Dec 3, 2014
@chancancode Thank for adding me to the repo! I'm honored.
I agree with you. It may be impossible or need dirty hack.
Anyway I start to implement defining method with checking it's argument. After that, I think about declare a variable.
oh, you'er totally right. sorry it's my mistake ; (
chancancode commentedon Dec 3, 2014
Sorry if it wasn't clear (I was typing on my phone), the last point was more of a question. I just checked and answered my own question, you can indeed do all of these in Java:
I suppose
String bandint dwould just be no-ops in the gem, but it would be quite tricky to get that work unless youmethod_missingeverything and return:variable_declarationor something like that...