Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
inox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LARA
inox
Commits
9d0f8a3f
Commit
9d0f8a3f
authored
10 years ago
by
Regis Blanc
Committed by
Etienne Kneuss
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
explaining basic imperative features
parent
24a79f90
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
doc/xlang.rst
+31
-3
31 additions, 3 deletions
doc/xlang.rst
with
31 additions
and
3 deletions
doc/xlang.rst
+
31
−
3
View file @
9d0f8a3f
...
@@ -33,18 +33,46 @@ syntax.
...
@@ -33,18 +33,46 @@ syntax.
The above example illustrates three new features introduced by XLang:
The above example illustrates three new features introduced by XLang:
1. Declaring a variable in a local scope
1. Declaring a variable in a local scope
2. Blocks of
statement
2. Blocks of
expressions
3. Assignment
3. Assignment
You can use Scala variables with a few restrictions. The variables can only be
declared and used locally in the same function, and inner functions cannot
close over them. XLang introduces the possibility to use sequences of
expressions (blocks) -- a feature not available in PureScala, where you're only
option is a sequence of ``val`` which essentially introduce nested ``let``
declarations.
.. warning::
Be careful when combining variables with nested functions from PureScala. Leon
will reject code with nested functions accessing a variable from an outside scope:
.. code-block:: scala
def foo(x: Int) = {
var a = 12
def bar(y: Int): Int = {
a = a + 1
a + y
}
bar(17)
}
The problem with such code is the complications involved in representing closures as
they need a pointer to an environment containing the variables. Leon is only able
to handle closures with ``val``, where it is sufficient to explicitly pass the values
as parameters.
While loops
While loops
***********
Arrays
Arrays
******
Nested function closure on local variables.
.. note::
.. note::
some note comes here
some note comes here
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment