Jean Privat [Mon, 4 May 2015 13:45:46 +0000 (09:45 -0400)]
version 0.7.4
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Sat, 25 Apr 2015 02:19:15 +0000 (09:19 +0700)]
Merge: Named arguments
Named arguments allows the caller to specify some subset of arguments it wants to call.
This PR introduce a syntax for callers inspired from the Python one (the Ruby one uses columns that clashes with types declaration).
~~~nit
format(linewidth=80, separator=":", indent=true)
~~~
The specification tries to be as simple as possible
* Only default parameters can be passed by name; because the other are mandatory.
This restriction is also useful to avoid to specify additional rules, like the last parameter of assignment methods, because the ones on default arguments apply.
~~~nit
fun foo(a,b: nullable Int) do ...
foo(b=1)
foo(null,1) # equivalent
~~~
* Named arguments can appear anywhere (not necessarily at the end)
~~~nit
fun foo(a: Int, b: nulable Int)
foo(b=1,2)
foo(2,1) # equivalent
~~~
* The order of evaluation is the order of the arguments (not the order of the parameters).
I think this is more POLA this way.
* The names to use are the one of the statically designated method declaration (not the introduction).
This one is problematic because the language permit the name of parameters to change in redefinitions.
But in case of errors or in a IDE it is often more useful to point the most precise method definition.
The implementation was trivial because the hard work was already done in the previous PR.
This PR was unlocked by #1280
Pull-Request: #1281
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Etienne M. Gagnon <egagnon@j-meg.com>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Romain Chanoir <chanoir.romain@courrier.uqam.ca>
Jean Privat [Sat, 25 Apr 2015 02:18:54 +0000 (09:18 +0700)]
Merge: Parallelization phase improvement
Adds the support of methods with return value
If you use `is threaded` on a method with a return, it will instead return you a custom instance of `Thread` class on which you can use the method `join` to retrieve the return of the annotated method. `join` waits for the method to end before returning.If you want to make sure that the method has done his work before trying to retrieve it's return value, you can check it with the boolean `is_done`
Pull-Request: #1278
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Reviewed-by: Jean Privat <jean@pryen.org>
Jean Privat [Sat, 18 Apr 2015 15:12:11 +0000 (22:12 +0700)]
tests: add base_arg_named_inherit.nit
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Sat, 18 Apr 2015 15:11:40 +0000 (22:11 +0700)]
tests: add base_arg_named.nit and base_arg_order.nit
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Thu, 16 Apr 2015 11:46:16 +0000 (18:46 +0700)]
engines: process named arguments
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Sat, 18 Apr 2015 15:22:40 +0000 (22:22 +0700)]
typing: process named arguments
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Thu, 16 Apr 2015 11:43:05 +0000 (18:43 +0700)]
parser: regenerate
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Thu, 16 Apr 2015 11:42:50 +0000 (18:42 +0700)]
grammar: add expr.namedargs
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Thu, 16 Apr 2015 11:42:17 +0000 (18:42 +0700)]
grammar: extract `vararg` in a specific arg production
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Thu, 16 Apr 2015 11:41:19 +0000 (18:41 +0700)]
model: add `MSignature::mparameter_by_name`
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Fri, 24 Apr 2015 08:24:01 +0000 (15:24 +0700)]
Merge: More binary operators
The first part of the PR cleanup and factorize some things related to the operators in the grammar and the AST.
Then the four bitwise operators are added.
Close #1271 unless some more thing is added to it (like generalized unary operators)
Note: as usual, github is useless when the parser is regenerated, so review the individual commits if you prefer.
Pull-Request: #1295
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Jean Privat [Fri, 24 Apr 2015 07:50:09 +0000 (14:50 +0700)]
tests: clean and complete test_ffi_c_operators
thanks nitpretty!
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Thu, 23 Apr 2015 10:01:55 +0000 (17:01 +0700)]
tests: update error_syntax2.nit because & is now an operator
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Thu, 23 Apr 2015 08:45:41 +0000 (15:45 +0700)]
tests: improve (and rename) test_operators.nit
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Thu, 23 Apr 2015 08:46:06 +0000 (15:46 +0700)]
src: handle new bitwise operators
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Fri, 24 Apr 2015 06:03:24 +0000 (13:03 +0700)]
Merge: nitdoc: prepare the migration of nitdoc component to new phases
Only internal modification, no diff with the generated HTML of the previous version.
If you don't trust me (I you shouldn't), the demos will be [there](http://gresil.org/jenkins/job/CI-nitdoc/ws/doc/stdlib/index.html) and [there](http://gresil.org/jenkins/job/CI-nitdoc/ws/doc/nitc/index.html) in a few minutes.
> Brace yourself, next PR on that subject will be big.
Pull-Request: #1293
Reviewed-by: Jean Privat <jean@pryen.org>
Jean Privat [Fri, 24 Apr 2015 06:03:14 +0000 (13:03 +0700)]
Merge: nitrpg: periodize stats
This will be used to display periodic stats about players and games.
Pull-Request: #1292
Reviewed-by: Jean Privat <jean@pryen.org>
Jean Privat [Fri, 24 Apr 2015 06:03:07 +0000 (13:03 +0700)]
Merge: Nitrpg work
Improve the dashboard on the player page with `request_for_comment` things, and assigned work
Pull-Request: #1291
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Jean Privat [Fri, 24 Apr 2015 06:02:47 +0000 (13:02 +0700)]
Merge: Hint vararg
Improve the error message so that user that try to pass an array as is instead of elements is hinted about the `...` reverse-vararg operator.
~~~
fun foo(xs: Int...) do end
foo(1,2,3) # OK
var a = [1,2,3]
foo(a) # Error, expected `Int`; got `Array[Int]`. Is `...` missing?
foo(a...) # OK
~~~
![](http://i.imgur.com/zmyi8GR.jpg)
close #98 (quite old bug)
Pull-Request: #1294
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Jean Privat [Fri, 24 Apr 2015 06:02:37 +0000 (13:02 +0700)]
Merge: Some metrics improvement and cleaning
Pull-Request: #1287
Reviewed-by: Jean Privat <jean@pryen.org>
Jean Privat [Fri, 24 Apr 2015 06:02:31 +0000 (13:02 +0700)]
Merge: Model: add mclassdef2node
This was missing, I don't understand why but I need it.
Pull-Request: #1288
Reviewed-by: Jean Privat <jean@pryen.org>
Jean Privat [Thu, 23 Apr 2015 06:10:28 +0000 (13:10 +0700)]
tests: update sav/base_vararg3* with new hint error message
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Thu, 23 Apr 2015 06:08:44 +0000 (13:08 +0700)]
typing: special message when a single vararg is refused bu could be `...`-ed
Signed-off-by: Jean Privat <jean@pryen.org>
Alexandre Terrasa [Wed, 25 Feb 2015 21:31:43 +0000 (22:31 +0100)]
contrib/nitrpg: use stats to store player nitcoins
So podium and stats can be displayed by time periods.
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Tue, 24 Feb 2015 19:15:20 +0000 (20:15 +0100)]
contrib/nitrpg: make stats periodized
Currently stats are stored:
* all time
* yearly
* monthly
* daily
* weekly
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Fri, 24 Apr 2015 02:00:03 +0000 (22:00 -0400)]
lib/counter: introduce Counter::dec
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Fri, 24 Apr 2015 01:05:12 +0000 (21:05 -0400)]
src/doc: introduce DocComposite HTML rendering services
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Tue, 21 Apr 2015 20:28:06 +0000 (16:28 -0400)]
metrics/mendel: add missing comments
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Tue, 21 Apr 2015 20:27:53 +0000 (16:27 -0400)]
metrics/mendel: use new constructors
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Tue, 21 Apr 2015 20:27:32 +0000 (16:27 -0400)]
metrics/mendel: sort results in console display
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Thu, 23 Apr 2015 18:57:23 +0000 (14:57 -0400)]
metrics: fixe missing documentation warnings
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Thu, 23 Apr 2015 18:58:32 +0000 (14:58 -0400)]
metrics: remove useless return types in redefs
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Thu, 23 Apr 2015 18:58:11 +0000 (14:58 -0400)]
metrics: move `sum` up to interface `Metric`
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Tue, 21 Apr 2015 20:26:29 +0000 (16:26 -0400)]
metrics: allow Metric sorting
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Thu, 23 Apr 2015 18:55:19 +0000 (14:55 -0400)]
lib/standard: introduce ReserveDefaultComparator
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Mon, 23 Feb 2015 20:43:10 +0000 (21:43 +0100)]
src/doc: introduce `html_comment` and `html_short_comment` services
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Mon, 23 Feb 2015 19:50:18 +0000 (20:50 +0100)]
src/doc: move components generation from `doc_model` to `doc_html` phase
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Jean Privat [Thu, 23 Apr 2015 08:30:35 +0000 (15:30 +0700)]
parser: regenerate
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Thu, 23 Apr 2015 08:30:00 +0000 (15:30 +0700)]
grammar: add bitwise operators `|`, `^`, `&`, and `~`
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Thu, 23 Apr 2015 08:24:56 +0000 (15:24 +0700)]
src: use AUnaryopExpr
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Thu, 23 Apr 2015 08:19:33 +0000 (15:19 +0700)]
parser: new class AUnaryopExpr to factorize unary operations
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Thu, 23 Apr 2015 08:16:54 +0000 (15:16 +0700)]
parser: new class AOperatorMethid to factorize operator methods
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Wed, 22 Apr 2015 16:11:36 +0000 (23:11 +0700)]
nitrpg: add new player panel for work to do
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Wed, 22 Apr 2015 16:11:20 +0000 (23:11 +0700)]
nitrpg: extends PlayerReviewsPanel to add `request_for_comments` tags
Signed-off-by: Jean Privat <jean@pryen.org>
Alexandre Terrasa [Tue, 24 Feb 2015 18:06:44 +0000 (19:06 +0100)]
contrib/nitrpg: `save_in` uses string key instead of GameEntity
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Jean Privat [Wed, 22 Apr 2015 06:46:03 +0000 (13:46 +0700)]
Merge: Small clean up and improvements to MNit from WBTW
The new OpenGL parameters affect the display of images for a better pixelated look:
* When zoomed out, the image is smoother, the color values are interpolated from the nearest source pixels.
* When zoomed in, the image is displayed pixelated.
You may recognize the `Int::next_pow` method, `inkscape_tools` use something similar for the same purpose. Actually, with this PR, `inkscape_tools` may not need it anymore and produce smaller PNG files.
Pull-Request: #1284
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Romain Chanoir <chanoir.romain@courrier.uqam.ca>
Jean Privat [Wed, 22 Apr 2015 04:18:41 +0000 (11:18 +0700)]
Merge: share/man: Update man for `nitpretty`
Fixes #1130
Pull-Request: #1290
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Reviewed-by: Jean Privat <jean@pryen.org>
Jean Privat [Wed, 22 Apr 2015 04:18:34 +0000 (11:18 +0700)]
Merge: Inkscape tool revamp and gamnit support
* Clean up old style inits, add missing doc and refactor main code into classes and methods.
* Adds the gamnit target option, the generated code is much more simple, but the generation a bit more complex.
* Allow to specify the full path to the Nit source file to generate.
* Make rounding to the next power of 2 optional, it will no more be required for mnit programs on Android with #1284.
Pull-Request: #1285
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Jean Privat [Wed, 22 Apr 2015 04:18:23 +0000 (11:18 +0700)]
Merge: Nitdoc: more cleaning and uniformize method names
Démos:
* [stdlib](http://gresil.org/jenkins/job/CI-nitdoc/ws/doc/stdlib/index.html)
* [nitc](http://gresil.org/jenkins/job/CI-nitdoc/ws/doc/nitc/index.html)
Pull-Request: #1283
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Romain Chanoir <chanoir.romain@courrier.uqam.ca>
Jean Privat [Wed, 22 Apr 2015 04:18:11 +0000 (11:18 +0700)]
Merge: nitrpg: minor enhancements
Mainly designed to fully close #1168 and work on #1161.
Pull-Request: #1185
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Jean Privat <jean@pryen.org>
Alexandre Terrasa [Tue, 21 Apr 2015 23:48:47 +0000 (19:48 -0400)]
nitpretty: fixes typo in option comment
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Tue, 21 Apr 2015 23:47:36 +0000 (19:47 -0400)]
share/man: Update man for `nitpretty`
Fixes #1130
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Tue, 21 Apr 2015 23:33:20 +0000 (19:33 -0400)]
contrib/nitrpg: add a Comparator to sort games by number of players
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Mon, 23 Feb 2015 13:10:48 +0000 (14:10 +0100)]
contrib/nitrpg: return 404 on bad urls
Fixes #1168
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Mon, 23 Feb 2015 12:54:23 +0000 (13:54 +0100)]
contrib/nitrpg: display the list of active games in /games
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Mon, 23 Feb 2015 12:50:27 +0000 (13:50 +0100)]
contrib/nitrpg: display the readme and the active game list in homepage.
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Mon, 23 Feb 2015 12:37:29 +0000 (13:37 +0100)]
contrib/nitrpg: factorize game loading service from GameAction
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Mon, 23 Feb 2015 12:36:41 +0000 (13:36 +0100)]
contrib/nitrpg: add GamesListPanel to display the list of active games
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Mon, 23 Feb 2015 12:36:20 +0000 (13:36 +0100)]
contrib/nitrpg: add MDPanel to display MDContent
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Mon, 23 Feb 2015 12:35:43 +0000 (13:35 +0100)]
contrib/nitrpg: add a README file
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Mon, 23 Feb 2015 11:07:04 +0000 (12:07 +0100)]
contrib/nitrpg: add some achievements on IssueComments
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Tue, 21 Apr 2015 20:24:18 +0000 (16:24 -0400)]
model: add missing service to retrieve a AClassDef from a MClassDef.
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Tue, 21 Apr 2015 20:23:43 +0000 (16:23 -0400)]
model: avoid running phase on fictive module
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexis Laferrière [Tue, 21 Apr 2015 10:09:24 +0000 (06:09 -0400)]
contrib/inkscape_tools: update README.md file
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
Alexis Laferrière [Tue, 21 Apr 2015 10:03:43 +0000 (06:03 -0400)]
contrib/inkscape_tools: make rounding to the next power of 2 optional
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
Alexis Laferrière [Sun, 19 Apr 2015 16:38:16 +0000 (12:38 -0400)]
contrib/inkscape_tools: add alternative code generation for gamnit target
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
Alexis Laferrière [Tue, 21 Apr 2015 09:56:21 +0000 (05:56 -0400)]
contrib/inkscape_tools: refactor main code into 2 new classes
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
Alexandre Terrasa [Mon, 23 Feb 2015 19:45:42 +0000 (20:45 +0100)]
src/doc: clean signature HTML output with `html_signature` and `html_short_signature`
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Mon, 23 Feb 2015 19:12:37 +0000 (20:12 +0100)]
src/doc: rename `tpl_namespace` in `html_namespace` also clean comments
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Mon, 23 Feb 2015 18:59:28 +0000 (19:59 +0100)]
src/doc: rename `tpl_declaration` in `html_declaration` and uniformize output
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Mon, 23 Feb 2015 18:17:31 +0000 (19:17 +0100)]
src/doc: rename `tpl_anchor` into `html_link_to_anchor` and use bootstrap template
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Tue, 21 Apr 2015 12:28:48 +0000 (08:28 -0400)]
src/doc: rename `tpl_link` into `html_link` and use bootstrap template
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexis Laferrière [Thu, 16 Apr 2015 15:40:44 +0000 (11:40 -0400)]
contrib/inkscape_tools: add option for the full path to the generated source
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
Alexis Laferrière [Thu, 16 Apr 2015 15:38:29 +0000 (11:38 -0400)]
contrib/inkscape_tools: revamp doc of svg_to_png_and_nit
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
Alexis Laferrière [Wed, 11 Mar 2015 15:10:09 +0000 (11:10 -0400)]
lib/mnit: fix and improve magnification for a pixelized (to smooth) look
The new OpenGL paramenter act of the display of images:
* When zoomed out, the image is smoother, the color values are interpolated
from the neares source pixels.
* When zoomed in, the image is displayed pixelized.
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
Alexis Laferrière [Sun, 22 Feb 2015 18:07:16 +0000 (13:07 -0500)]
lib/mnit: print the approximate memory used by textures loaded in memory
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
Alexis Laferrière [Sun, 22 Feb 2015 17:55:49 +0000 (12:55 -0500)]
lib/mnit: expand images to the nearest power of 2 for OpenGL ES 1.0
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
Alexis Laferrière [Sun, 22 Feb 2015 17:54:03 +0000 (12:54 -0500)]
lib/mnit: use PRINT_ERROR instead of printf on portable code
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
Alexis Laferrière [Thu, 16 Apr 2015 15:37:35 +0000 (11:37 -0400)]
contrib/inkscape_tools: remove old_style constructor and whitespace error
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
Jean Privat [Sun, 19 Apr 2015 00:07:12 +0000 (07:07 +0700)]
Merge: Default arguments
Default arguments (aka parameters with a default value) are often a nice way to provide a complex operation with a lot of variations but allow the client to use it in a simple form when no complexity is required.
Also, it allows to extends the signature of existing operations while being API-compatible with previous versions.
This PR introduces default arguments to Nit as another tool in the toolbox of library designers.
The specification is quite simple:
* a nullable parameter can be ignored, the value of the argument will default to null
~~~nit
fun foo(a: Int, b: nullable Int) do ...
foo(1)
foo(1, null) # equivalent thing
~~~
* default parameters can be anywhere (not necessarily at the end)
~~~nit
fun foo(a: nullable Int, b: Int) do ...
foo(1)
foo(null, 1) # equivalent thing
~~~
* when there is multiple possible associations between arguments and parameters, arguments will be associated to the leftmost (first) parameter first.
~~~nit
fun foo(a, b: nullable Int) do ...
foo(1)
foo(1, null) # equivalent thing
~~~
* if there is a vararg, all other parameters are mandatory (no default)
~~~nit
fun foo(a: Int..., b: nullable Int) do ...
foo(1) # Error: minimum 2 arguments (we chose that varargs require a minimum of 1 argument, but this old choice is a different issue)
foo(1, 2) # OK
foo([1]..., 2) # equivalent thing
~~~
* the last parameter of an assignment method (that is the right value of the assignment) is never default. For POLA reasons, the last argument is distinguished and syntactically mandatory, so the association with the parameter is always direct and unambiguous.
~~~nit
fun foo=(a, b: nullable Int) do ...
foo = 1
foo(null) = 1 # equivalent thing
~~~
I chose this specification because it uses the nullable facility of Nit in a nice way and is somewhat semantic: `null` means nothing to say, or keep it blank.
I prefer it over the specification of other languages that is to declare a specific default value on the declaration of parameters.
* no need not to update the grammar
* no need to specify the language of the default value (any expressions? only literal? other?)
* no need to specify when and by who the default value is evaluated (and what is the value of self? are the other parameters usable in the expression? etc.)
* no need to specify how to deal with default values on redefinitions in a OO point of view (do I inherit the default value? can I `super` the default value?)
* no need to expose the expressions used as default values in the metamodel
* no need to expose the expressions used as default values in the doc
Most of these things make the language less KISS (obviously), and less POLA because whatever spec we can choose for these points, 1) not 100% of user will find them obvious; and 2) for some cases the wanted behavior will not be the specified one.
Note that in Python, while they allow to define a specific default value on parameters, they recommend to use `null` as a default to avoid most of these aforementioned problems.
Note2: this PR was unlocked by #1269 and #1268
Pull-Request: #1280
Reviewed-by: Etienne M. Gagnon <egagnon@j-meg.com>
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Reviewed-by: Ait younes Mehdi Adel <overpex@gmail.com>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Jean Privat [Thu, 16 Apr 2015 11:40:15 +0000 (18:40 +0700)]
tests: add base_arg_default*.nit
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Sat, 18 Apr 2015 14:49:32 +0000 (21:49 +0700)]
neo: save MParameter::is_default
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Sat, 18 Apr 2015 13:40:26 +0000 (20:40 +0700)]
typing&engines: implement default arguments
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Thu, 16 Apr 2015 11:11:09 +0000 (18:11 +0700)]
model&modelize: introduce default parameters
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Sat, 18 Apr 2015 09:47:34 +0000 (16:47 +0700)]
Merge: Snake phase names
Default name of phases where based on a lower cased version of their classnames.
That was bad. eg `FFILanguageAssignationPhase` -> `ffilanguageassignation`
So this PR snakecase them instead.
But the spec of `to_snake_case` was awful: `f_f_i_language_assignation`
So also fix the spec of this method and get something nice `ffi_language_assignation`.
Pull-Request: #1276
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Reviewed-by: Romain Chanoir <chanoir.romain@courrier.uqam.ca>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Jean Privat [Sat, 18 Apr 2015 09:47:26 +0000 (16:47 +0700)]
Merge: Microbenches for niti
Some update on tests/ so that niti (and nitvm) can pass more tests
Pull-Request: #1275
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Reviewed-by: Romain Chanoir <chanoir.romain@courrier.uqam.ca>
Jean Privat [Sat, 18 Apr 2015 09:47:17 +0000 (16:47 +0700)]
Merge: Autocast and literal arrays
Small bugfixes
* forbid autocasts in combined assignments and literal arrays
* keep autocast information in transform
* rta visits implicit methods of literal arrays
Only the first one was the original bug I wanted to fix, the two others where discovered and solved while writing the PR.
Pull-Request: #1272
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Reviewed-by: Romain Chanoir <chanoir.romain@courrier.uqam.ca>
Jean Privat [Sat, 18 Apr 2015 09:47:09 +0000 (16:47 +0700)]
Merge: Option --keep-going
Follow up of #959 and #1241. Now an option is exposed so people can happily try to use it on various tools that will turn them berserk and make them want to kill you.
Pull-Request: #1270
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Reviewed-by: Romain Chanoir <chanoir.romain@courrier.uqam.ca>
Jean Privat [Sat, 18 Apr 2015 09:47:00 +0000 (16:47 +0700)]
Merge: Check operator
Previously, no checking was done on the signature of operators.
While this is not an issue for the model nor the tools this could yield to not POLA error messages when the operator is used. eg.
~~~nit
class A
fun +(other: A) do print "hello"
end
var a = new A
var b = a + a # Error expected expression
a + a # Error unexpected operator +
# no way do invoke `+` in fact.
~~~
With the PR, we have
~~~
Error: mandatory return type for `+`.
fun +(other: A) do print "hello"
^
~~~
The following errors are added by the PR:
* mandatory return
* not enough parameters
* too much parameters
* illegal variadic parameter
Pull-Request: #1269
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Reviewed-by: Romain Chanoir <chanoir.romain@courrier.uqam.ca>
Jean Privat [Sat, 18 Apr 2015 09:46:51 +0000 (16:46 +0700)]
Merge: Signature map
Provide an abstraction `SingatureMap` to factorize (and simplify) the association between arguments and parameters (not that easy in the context of varargs).
This PR is also required by a future PR.
Pull-Request: #1268
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Reviewed-by: Romain Chanoir <chanoir.romain@courrier.uqam.ca>
Jean Privat [Thu, 16 Apr 2015 13:34:47 +0000 (20:34 +0700)]
tests: update test_ffi_c_operators for << and >>
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Thu, 16 Apr 2015 11:04:11 +0000 (18:04 +0700)]
tests: add error_operators.nit
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Thu, 16 Apr 2015 11:01:11 +0000 (18:01 +0700)]
modelize_property: implement special validity rules for operators
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Sat, 18 Apr 2015 09:36:31 +0000 (16:36 +0700)]
tests: update test_new_native.res because line change in array.nit
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Thu, 16 Apr 2015 09:57:27 +0000 (16:57 +0700)]
interpreter: use SignatureMap to make varargize more robust
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Thu, 16 Apr 2015 09:55:39 +0000 (16:55 +0700)]
compiler: use SignatureMap to make varargize more robust
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Fri, 17 Apr 2015 15:54:39 +0000 (22:54 +0700)]
lib/standard/array: add `Array::sub`
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Fri, 17 Apr 2015 07:25:35 +0000 (14:25 +0700)]
phases: default names is the snake_cased version of the classname
use `nitc --disable-phase list` to see them
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Fri, 17 Apr 2015 07:24:39 +0000 (14:24 +0700)]
strings: reimplement to_snake_case with a correct semantic
Signed-off-by: Jean Privat <jean@pryen.org>