inicio mail me! sindicaci;ón

E, episode four (Basics)

E ships with a command line interpreter, named rune useful to test scripts and examples. The configuration file also has the capability to save trace log where you want useful to examine errors separately to not clog the terminal window everytime.

Basics

E has variables (declared with var statement) and constants (declared with def). The assignment is done with “:=” operator, no “=” sign, comparison is done with “==”. So “=” it’s illegal. Remember that.

Statements are ended with new line (no useless “;” or something else).

Basic data types are int, float, string, char, boolean.

Variable sostitution can be done with back-tics “`” in this way:

[code lang="javascript"] def x := 3 def printString := Value of x is: $x [/code]

Strings are somewhat like Java’s.

A big difference with Java behavior is about comparison with “==” and “!=”:

== and != are the boolean tests for equality and inequality respectively. When the equality test is used between appropriately designated transparent immutables, such as integers, the values are compared to see if the values are equal; for other objects the references are compared to see if both the left and right sides of the operator refer to the same object. Chars, booleans, integers, and floating point numbers are all compared by value, as in Java. In addition, Strings, ConstLists, and ConstMaps are also compared by value, which makes it different from, and more natural than, Java.

Flow control structures are: if/else, while, try/catch/finally, throw (you can raise strings also, like Python…), break (supports an optional argument, the return value of the loop), continue, switch and for.

The powerful flow control structure is for because allows the developer to loop not only over ranges of numbers

[code lang="javascript"] for i in 1..3 { println(i) } [/code]

or lists

[code lang="javascript"] for j in ["a", 1, true] { println(j) } [/code]

but also over maps (hashtables), text files, directories and every structure implementing the iterator pattern.

Related posts

  • E, episode six (I/O)
  • Learning Prolog On Christmas Eve
  • Project thoughts
  • E, episode eleven (The Dream)
  • E, episode thirteen (Conclusions)
  • Gravatar

    A song for the lovers » Blog Archive » E, episode six (I/O) said,

    February 7, 2006 @ 5:32 pm

    [...] As said in a previous post you can use the “for” loop to iterate over text files and directories easily. E is also platform indipendent about end-line markers (the only operating system not using “n” is Windows). It translates them automatically for you. [...]

    RSS feed for comments on this post · TrackBack URI

    Leave a Comment