[Gambas-user] New feature in Gambas 3 development version
Benoit Minisini
gambas at ...1...
Mon Sep 1 03:01:18 CEST 2008
Hi,
If you use the development version, now you can declare typed object arrays:
DIM ArrayOfLabels AS Label[8, 8]
The Label[] class is dynamically created by the interpreter the first time it
is used.
It has exactly the same features as the Object[] class, except that it always
returns Labels, not Objects.
So, something like:
ArrayOfLabels[1, 1].Text = "Hello"
becomes faster as the interpreter now knows that ArrayOfLabels[1, 1] returns a
label, and so can optimize the property access.
This feature is more powerful. Any class can be followed by "[]" to become an
typed array class, and this process is recursive.
So "String[][][]" is an array of array of array of String! I don't know if it
useful in that specific case...
At the moment, the IDE automatic completion does not understand this new
syntax. But it is planned.
I want to enhance this "template" feature: I'd like to do something like:
DIM MyIndex AS String.Collection
to be able to declare a Collection whose elements are strings. It could be
faster than using the standard Collection, whose elements are variants.
Then we will be able to do weird things, like:
DIM WhatTheFuck AS String.Collection[].Collection
That would be a Collection whose elements are arrays of Collection whose
elemnts are String.
And maybe we could go further: using any class as template. Something like:
DIM MyListOfString AS String.List
where List is a class written in Gambas.
I don't know that last feature would be really useful anyway.
Waiting for people comments now... :-)
Regards,
--
Benoit Minisini
More information about the User
mailing list