What's the status of "var" variables?

Hi.
What's the status of "var" variables?
I'm using MPS 3.1.3 and I've written the following simple code:


public class TestCCC {
   
  public TestCCC() {
    var jj = 5;
      
  }
}


And there is an error:
"type int is not a subtype of var"

The "var" node is:

node://jetbrains.mps.baseLanguage/jetbrains.mps.baseLanguage.structure/VarType


Is the error occurring, because, perhaps, is there some typesystem rule perhaps missing?

Best,
Karol Depka Pradzinski
7 comments
By the way, apart from "var", is there a corresponding "val" or "let" as in Scala or Swift ?

By the way, this is actually in a broader context - I'm testing out baseLanguage extensions, like this, and comparing them to Scala, Swift, C#.

Best,
Karol
0
VarType is no longer maintained and will be most likely removed in one of the upcoming releases.
0
Hi Vaclav.
Thank you for your reply.
What's the reason for abandoning it?
How broadly was it used?
Is there a replacement?
Apparently, a modern language has to have some form of type-inferred var/val/let, what do you think?
What the status/plan for it in MPS?

Best,
Karol Depka Pradzinski
0
Hi Karol,

I agree that type-inferred variable declarations are a useful feature of many modern language. The VarType in BL, however, has not really been used at all in the MPS codebase and given that we haven't heard any complains about it malfunctioning I suspect it is not widely used outside JetBrains either.
BL is primarily a projectional Java clone and I'd prefer having it extended through extensions rather than by modifying the language itself. Each such feature adds to the complexity of the language and thus we should only maintain those that bring benefits to the users.

Vaclav
0
Hi Vaclav.
Thank you for your reply.
So is there something like a var type that is shipped in an extension, as opposed to "core BL" ?
It stopped functioning for some compatibility reasons, right?
Maybe I could try to fix it?
Or is there some fundamental barrier that appeared recently, preventing it form working?

Best,
Karol
0
I remembered seeing this blog post, which I think describes what you are looking for (the var part, as a BL extension). It should not be too difficult to extend it to support val:

http://logv.ws/b/2014/03/16/java-extensions-101-with-mps/

I would encourage the author to post it as a language plugin to the MPS repo so that it is more easily discoverable.
0
Hi Karol,

I'm not really sure how the VarType has evolved over type or when it stopped working. Nobody has been maintaining it for quite a while.

If you feel that this is something that BL would benefit from and are willing to contribute, I'm tempted to suggest that we could make it part of the BaseLanguageExtensions plugin (https://github.com/vaclav/BaseLanguageExtensions, http://plugins.jetbrains.com/plugin/7101?pr=mps).

Please let me know your thoughts.

Vaclav
0

Please sign in to leave a comment.