Jamie McCracken (jamiemcc) wrote,
Jamie McCracken
jamiemcc

Genie Improvements

I know there is a lot of excitement generating around this uber cool new Genie programming language and i am happy to report more progress including more documentation at that site (i know more needs doing there + more examples but they are on the way)

I have now made lists (dynamic arrays) and dicts (hashtables) first class datums in Genie. As they utilise the tiny and useful libgee, you will need this library installed if you make use of these. You will also need latest svn version of vala too.

Anyway here is a small taste of lists and dicts in action:

[indent=4]

init

    /* test lists */
    var l = new list of string
    
    l.add ("Genie")    
    l.add ("Rocks")
    l.add ("The")
    l.add ("World")

    for s in l
        print s
    
    print " "
    
    l[2] = "My"
    
    for s in l
        print s

    print " "

    /* test dicts */
    var d = new dict of string,string

    d["Genie"] = "Great"
    d["Vala"] = "Rocks"
    
    for s in d.get_keys ()
        print "%s => %s", s, d[s]


to compile you must use libgee so compile with:
valac --pkg gee-1.0 genie-list.gs

output is:
Genie
Rocks
The
World
 
Genie
Rocks
My
World
 
Vala => Rocks
Genie => Great

The big advantage of embedding lists and dicts in the language is that it makes it much easier for the developer to make use of them. It also means genie can make decisions about which hashing and equal functions to use based on the types (Eg for a dict of string,string it would use the glib g_str_hash and g_str_equal functions automatically although you could of course specify different ones by setting the properties explicitly) whereas in vala you would have to type something like :
var map = new Gee.HashMap<string, string>(GLib.str_hash, GLib.str_equal);

which is a bit long winded and embedding them allows us to avoid this.

Anyway in the future we also want to support initializers and type inferencing of the list/dict EG the above dict in the future could be created as
var d = {"Genie" = "Great", "Vala" = "Rocks"}

but that of course needs more work!

Also I have create a feedback wiki page for genie here so feel free to put suggestions there (but be nice!)
Subscribe

  • Post a new comment

    Error

    default userpic

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 37 comments
Previous
← Ctrl ← Alt
Next
Ctrl → Alt →
I just cant stop reading this. Its so cool, so full of information that I just didnt know. Im glad to see that people are actually writing about this issue in such a smart way, showing us all different sides to it. Youre a great blogger. Please keep it up. I cant wait to read whats next.
mupv kutoq [URL=http://www.katesxxx.com]pornstars[/URL] xcrxcr v lb p jqs

Anonymous

August 12 2016, 02:12:25 UTC 4 years ago

I am finding documentation of Genie to be very sparse. Is there a comprehensive list of commands, operators, methods, etc.?

Anonymous

February 22 2019, 11:23:37 UTC 2 years ago

your spam filter sukks big time
Previous
← Ctrl ← Alt
Next
Ctrl → Alt →