-
Notifications
You must be signed in to change notification settings - Fork 16
Wollok v1.3 Confucius
We have upgraded versions of many underlying core technologies used by wollok
- Java from 1.7 to 1.8: so beware that you now need a JDK8
- Xtext from 2.7.3 to 2.9.0: You will probably need to download the wollok IDE again, or install the plugins again in a new upgraded eclipse (Mars) if you manually installed it.
- Eclipse from Luna to Mars: same as above
We have changed the keyword that express class/WKO inheritance, instead of "extends" which has a broaden sense we now use inherits
class Dog inherits Animal {
// ...
}
You can have a catch block without specifying the type of the exception. In this case it will catch any wollok.lang.Exception (root class of all exceptions)
try {
a.m1()
}
catch e
console.println("blah")
We have done a very big refactor in the way Wollok implements "special" objects that comes with the language like booleans, strings, numbers, collections. Before v1.3.0 this where special object types that were part of the Wollok inner code. We have now modeled them in wollok language. They are part of the Wollok SDK library that is shipped automatically with Wollok language.
Here is a sample class diagram:
This means that all:
- You can now browse this classes for wollokdoc and for the implementation.
- other wollok mechanism like autocomplete or checks work for this basic objects
- Wollok Interpreter code is now more consistent.
Well-known objects can now inherit from classes which don't have a default constructor, and therefore require you to explicitly call a super constructor
A method can now declare that its last parameter is a vararg, which means that it can be called with a variable number of arguments, from 0 (zero) to "N".
Wollok will automatically wrap all those arguments in a list and call the method. So, from the method implementation point of view is just a list.
Here is a sample method declaration
Notices that it is a regular parameter followed with three dots. This are all valid calls
s.preffix("a", 1)
s.preffix("a", 1, 2)
s.preffix("a", 1, 2, 3)
s.preffix("a", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)
We added several new static checks for errors and warnings that should really improve the experience working with Wollok. They should now catch errors sooner during coding instead of later in runtime with weird error messages and exceptions.
Similar to what the checker does to messages sent to "this", now it also validates messages to well-known objects (named objects, those defined with 'object x { ... }'
In some cases, Wollok can detect that the corresponding method at a message sending does not return a value when it's expected to do it, according to the message sending context. For example, when the hypothetically returned value is assigned to a variable or is a part of another expression. For the moment (without using the type system) those are:
- messages sent to this
- messages sent to super
- messages sent to well-known objects
In such a cases Wollok will now check if you are trying to use the return value of the message, and if it finds out that you are expecting a value but the method won't produce any value (doesn't have a return statement or uses the shorthand for methods returning a value) it will produce an error.
In this case "eat" doesn't return any valueIt's a common pitfall to forget the return statement. The checker now analyses the methods' body and, if they seems to be generating a value but the method is not returning it, it will raise a warning.
Now methods that have a return statement are analysed to make sure you are returning values on every possible flow.
The try catch with more than one catch blocks is now being checked to see if some of the catches are being hidden by a previous catch block
For example:
try {
a.m1()
assert.fail("Should have thrown exception")
}
catch e : AException
assert.fail("incorrect catch !")
catch e
console.println("blah")
// XPECT errors --> "Unreachable catch block" at "e"
catch e : BException
assert.fail("incorrect catch !")
Here BException catch is unreachable since BException is a subclass of AException
Imports are now being checked to make sure they are valid. This checking is still limited. For the moment it just checks whether the file (the first segment of the package is defined by the file name) is valid.
In order to make it fun working in Wollok for more advanced developers, we have added new quick fixes for static checks, which should improve development experience and speed.
For the new check of messages to WKO we provide a quick fix to create a new method. It currently only works for objects defined in the same file.
In case you forgot it
Exception handling has been improved a lot. Now there should only be a minimum number of scenarios where you will see a really long "java stack trace". Instead, you should now see a Wollok stack-trace similar to the following screenshot (if not, please report a bug ;) )
We have made some majors improvements to the Wollok IDE (meaning the more visual concerns).
Wollok bundle now contains the eclipse spanish language pack by default. This means that when you run it in spanish (because of your locale or specifying the option "-nl es") not only the wollok specific parts will be in spanish but the whole product and eclipse platform will also be in spanish.
Here are some screenshots
Now you can navigate certain messages to methods with CTRL+click or F3
For the moment this only works for messages being sent to:
- this
- super()
- well-known objects
Resolving any message will require to have a type system.
The content assist now got more clever. It will propose you real messages you can send to:
- this
- well-known objects
Example messages to this
Messages to WKO
In case you are sending a message to any other object besides this and a WKO, it will only show you the list of messages you already sent to that variable within the context. Which is the best we can do without a type system.
Wollok now analyses the reference initialisation to find out the expected (potential) type of the variable. Then it uses that information to create the autocomplete with methods belonging to the resolved type. This is a very basic type inference mechanism. Currently, it only works on the most simple cases where the reference is assigned with a literal object or a call to a constructor:
Examples here
val a = "abc" // wollok.lang.String
val a = 2 // wollok.lang.Integer
val a = 2.1 // wollok.lang.Double
val a = #[1, 2, 3] // wollok.lang.List
val a = #{1, 2, 3} // wollok.lang.Set
val a = console // console object
val a = new Bird() // Bird
If you are trying to send a message to a parameter, then we will analyse other methods of the current class/object and if we find a parameter with the same name, we will propose you the same messages as the ones you are sending on that other method.
Here is an example:
Besides checks, we also have autocomplete for imports now.
It now shows the inheritance relationship between a Well-Known-Object and its super class
It also shows the whole inheritance chain even if the classes are outside of the current file.
We started to customize the eclipse to cut-off some advanced features that will probably confuse newcomers and students. For the moment we have tailored down the wizards options to the following
The REPL console now has syntax highlighting. This is useful to differentiate the input lines from the output given by the wollok REPL (interpreter). It also highlights errors, and tries to highlight the input code you write in a similar way as the text editor (keywords, strings, variables, etc)
Part of the highlighting is actually done at the REPL size, so if you run the REPL from a console you will still see colors. Although not the full highlight as you will see in the Eclipse. Here is a sample with a bash console
There's a new button on the REPL console, which allows you to export the current session as a Wollok test. It doesn't export the whole history (which is longer than the current session), only the lines you just wrote on this session.
Here is a sample generated test
Starting from this release we are including and shipping "wollok game" along with Wollok. WollokGame is a project implemented by Nahuel Palumbo, Juan Contardo and Carlos Raffellini as part of their Grade Thesis.
This is the start of a new working line for wollok to provide a level of "gamification" to the OOP learning experience. It is not an attempt to provide a framework to developers/students to code complete "games", but a way to easily have a graphical interface for domains.
Here are some screenshots:
And
We want the student/developer to focus on the domain model behaviour and not geometry or graphical concerns. Still we want their domains to look and behave like in a game. So part of this research line is to try and test different approaches for this.
You can take a look at some sample game prototypes from this github repository
https://github.com/ProyectoFinal2015/ejemplos-wollok https://github.com/javierfernandes/wollok-wakman
Here is the complete set of issues solved in this release