Skip to content

Wollok v1.3 Confucius

javierfernandes edited this page Nov 19, 2015 · 22 revisions

Language

Syntax

"inherits" instead of "extends"

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 {
   // ...
}

New features

Coding Wollok in Wollok

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:

screen shot 2015-11-19 at 13 19 40

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.

Objects can now inherit from classes which require a constructor call

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

screen shot 2015-10-21 at 23 41 00

Checks / Validations

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.

Check messages to Well-Known Objects

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 { ... }'

screen shot 2015-10-13 at 22 29 13

Check non-return method usage

For some messages being sent Wollok can resolve them a particular methods. 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.

screen shot 2015-10-13 at 23 31 18 In this case "eat" doesn't return any value

Warn for missing return on methods

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, since it is a common pitfall to forgot the return statement.

screen shot 2015-10-14 at 15 02 56 screen shot 2015-10-14 at 15 03 06

Must return on every possible flow

Now methods that have a return statement are analysed to make sure you are returning values on every possible flow.

screen shot 2015-11-13 at 12 28 00

Quick-Fixes

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.

Create method on Well-Known Object in it doesn't exist

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.

screen shot 2015-10-13 at 22 34 43

Add return keyword when missing

In case you forgot it screen shot 2015-11-19 at 13 13 33

IDE

We have made some majors improvements to the Wollok IDE (meaning the more visual concerns).

Code Navigation for Messages -> Methods

Now you can navigate certain messages to methods with CTRL+click or F3

wollok-navigate-messages

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.

Content Assist

Autocomplete for Messages to this and WKOs

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 screen shot 2015-10-15 at 11 12 41

Messages to WKO screen shot 2015-10-15 at 11 12 53

In case you are sending a message to any other object besides this and a WKO, it will only shows 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.

Potential match based on other parameters

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:

screen shot 2015-10-21 at 22 54 48

REPL

Syntax Highlight

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)

screen shot 2015-10-16 at 23 00 37

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

screen shot 2015-10-15 at 16 32 21

Export Session as Test

There's a new button on the REPL console which allow you to export the current session as a wollok test. It doesn't export the whole history (which is longer than the current session), just the lines you just wrote on this session.

screen shot 2015-10-20 at 23 55 03

Here is a sample generated test

screen shot 2015-10-20 at 23 55 14
Clone this wiki locally