Saturday, May 28, 2011

LIB2: Tutorial, part 1

As work continues on LIB2 more samples are moved to it. So it's time to take a look at the changes the new library brought with it

#symbol Program =>
[
'program'Output << "Hello World!!%n".

'program'input get. // wait for any key
].

As you can see little was changes: a generic message GET is used instead of CHAR'GET. So let's look at more complex sample: words

#define std'basic'*.
#define std'collections'*.
#define std'patterns'*.
#define ext'text'*.
#define ext'patterns'*.
#define ext'routines'*.

#subject std'dictionary'*.

#subject total_words, unique_words.

// --- WordList ---

#class WordList
{
#field theList.
#field theTotal.

#method new
[
theList := List.
theTotal := Integer::0.
]

#method += aWord
[
theTotal += 1.

#if (ListSearching::theList ==aWord)?
| [ theList += aWord literal. ].
]

#method total_words = theTotal.

#method unique_words = theList count.

#annex (theList).
}

// --- Program ---

#symbol Program =>
[
'program'output << "Enter the text(to stop press enter two times):%n".

#var aFlag := Boolean << True.
#var aText := TextWriter.
#var aWriter := #annex(aText)
{
<< aLiteral
[
#if (aLiteral length == 0)?
[
aFlag << False.
]
| [ aText << aLiteral. ].
]
}.

#loop aFlag?
[
'program'Input >> aWriter.

aWriter += " ".
].

#var aList := WordList.

WordScan::aText run: aWord => (aList += aWord).

'program'output << "There are " << aList unique_words << " unique words out of " << aList total_words.
'program'output << "%nthe list of unique words:%n".

aList~CollectionPrinter save:'program'output.

'program'input get. // wait for any key
].

The first thing that catch an eye is a possibility to use symbol names without a namespace qualifier or an alias. New modules (like ext'routines) and classes (ext'text'TextWriter) were introduced. ext'patterns'WordEnum was renamed to WordScan. An external role ext'routines'CollectionPrinter is used to print the collection. Qualified messages unique_words and total_words are used instead of private ones $getTotal and $getUnique. Apart from these the sample logic remains the same: with the help of wordscan the entered text is split into words and only unique words are saved in the collection; the resulting list is printed at the end.

Friday, May 27, 2011

"Weekly" release 1.6.1.1

This is a weekly service release. It contains several major changes in ecodes(complete overhaul of ELENA bytecode opcodes, making this release incompatible with 1.6.1), some changes in group support, multiple dispatching. The migration to LIB2 continues, several samples were moved to it

  • it is possible now to switch to a role inside another one
  • new ecode: snop
  • run-time multi-dispatching
  • obsolete argument option: norecc
  • new argument option: nullable
  • intsum & realsum migrated to lib2
  • binary migrated to lib2
  • new compiler option - g0
  • ecodes are simplified, several big commands are split
  • #continue is no longer supported
  • words migrated to lib2
  • some basic byte code optimization rules
  • new option to turn on / off optimization - ox

You may download it from sourceforge - ELENA 1.6.1.1

The next several posts will discuss what's new in LIB2 comparing with the LIB

Thursday, May 5, 2011

ELENA 1.6.1 released

ELENA 1.6.1 is out now

This major release includes changes in the language syntax, several critical bug fixes and enhancements in the language library code.

1.6.1 is not binary compatible with the previous versions (due to changes in ecodes and a grammar)

multi-threading support

GCX (a revised garbage collection) is now thread-safe

changes in ecodes (ELENAVM byte codes)

  • several “big” commands are split, to reuse existing ecodes (disptach, redirect)
  • new ecode – popn

simplified syntax to create a group

instead of old style syntax

#group(events'EHandler, BtmSave) += …
it is possible to use the following syntax
BtmSave~events'EHandler += ..

#define command without an alias

it is possible to include another namespace without providing a namespace shortcut

#define std'basic'*.

Integer << 2.

new compiler hint syntax

instead of old style

#hint(subj:mysubject)
#class MyClass {…}
a new syntax is introduces
#class(subj:mysubject)MyClass {…}

#hint is no longer supported

the new hint syntax should be used

several major changes in an expression syntax

The following syntax

A verb:B::C
should be replaced with
A verb:(B::C)

An argument list could be used in initializing expression
A::&arg1:B &arg2:C
The following code do not need an extra brackets any more
#inline alias(A, B, C) verb:D

several bug fixes

  • a bug in memory management
  • a #group statement bug for x platform
  • cannot compile class with roles in the release mode bug
  • #00058: duplicate subjects
  • #00059: win32_gui_vm_client and win32_console_vm_client applications do not work
  • #00060: #var a := a verb:b circular referencing
  • upndown bug:player plays with a joker as a biggest one
  • bug: 64bit integer numbers are displayed incorrectly in the debugger watch window

lib2

  • the work on an alternative system library is began. LIB2 will replace existing one after 1.7.0
  • hellowworld_u sample migrated to lib2

IDE

IDE is now ready to debug multi-threading applications