1. Sequences?

Hello all,

In Euphoria everyone knows how sequences are formed

sequence seq
seq = {data1, data2, data3}

Now in C suppose an "array" is missing size value or,
has an (incomplete type)
i.e: int seq[]

/* if you create a struct named sequence
struct sequence;

/* and define the struct
typedef struct sequence seq;

/* later call to struct to fill sequence
struct sequence {
                          double data1, data2, data3
                         };

/* now seq should be
seq = {data1, data2, data3} -- same as Euphoria

AM I RIGHT?

I have absolutely none what-so-ever Knowledge
of C/C++ just reading up on the language
to help put into perspective the Eu 2 C translator...

euman at bellsouth.net

new topic     » topic index » view message » categorize

2. Re: Sequences?

On Sun, 03 Dec 2000, Euman wrote:
>> Hello all,
>>=20
>> In Euphoria everyone knows how sequences are formed
>>=20
>> sequence seq
>> seq =3D {data1, data2, data3}
>>=20
>> Now in C suppose an "array" is missing size value or,
>> has an (incomplete type)
>> i.e: int seq[]
>>=20
>> /* if you create a struct named sequence
>> struct sequence;
>>=20
>> /* and define the struct
>> typedef struct sequence seq;
>>=20
>> /* later call to struct to fill sequence
>> struct sequence {
>>                           double data1, data2, data3
>>                          };
>>=20
>> /* now seq should be
>> seq =3D {data1, data2, data3} -- same as Euphoria
>>=20
>> AM I RIGHT?
>>=20
>> I have absolutely none what-so-ever Knowledge
>> of C/C++ just reading up on the language
>> to help put into perspective the Eu 2 C translator...
>>=20
>> euman at bellsouth.net

Euphoria sequences are ordered and indexable, C/C++ structs are not, they=
 are
just an bubble around the data (and/or routines)

--=20
evil, corruption and bad taste
^[cense]

new topic     » goto parent     » topic index » view message » categorize

3. Re: Sequences?

^[cense]

>>Euphoria sequences are ordered and indexable, >>C/C++ structs are not,
they are
>>just an bubble around the data (and/or routines)

You can in the example (I gave in a prior post)
use the array subscript to access any element in the
array and from the doco i have on the subject the array
is pre-sized & ordered by the compiler..

BTW,
If i understand from the documentation i have,
the only differences would be nested sequences or
(multidimensional arrays) where-as
only the leftmost subscript bound can be omited
i.e: sequence[][2]

Whats confusing for me at this point is
useing pointers in the struct to access literal strings

I'm probably more than way off base so, I'll shut-up
and study pointers some more......Thanks

euman at bellsouth.net

new topic     » goto parent     » topic index » view message » categorize

4. Sequences?

How are sequences implemented in Euphoria, anyway?

--
Ryan Zerby, Senior Programmer   ryanz at netrex.com
"to create out of his own imagination the beauty of his wild forebears
--a mythology he cannot inherit." -- Allen Ginsberg 'Wild Orphan'

new topic     » goto parent     » topic index » view message » categorize

5. Re: Sequences?

Ryan Zerby asks:
> How are sequences implemented in Euphoria, anyway?

As you are probably aware, Euphoria (ex.exe/exw.exe)
is written in C. Therefore a Euphoria sequence has to be
represented in memory using C data structures. The way
that a sequence is represented has changed several times
over the years, without requiring any Euphoria code to
be rewritten, and in most cases without anyone even noticing.

I started off with the notion that sequences were like Lisp
lists and should therefore be implemented using linked
lists. This carried a lot of memory overhead for the links,
and made subscripting quite slow, so I rewrote the whole
interpreter to make sequences more like arrays.

Several iterations later we now have the current
structure (which changed again slightly in 1.5a).

Sequences are currently implemented as a header,
followed by an array of 4-byte values. 1 bit in each
value tells the interpreter whether the value is an
integer or a pointer to something. That's why the
Euphoria integer type is 31-bits, not 32. If it's a pointer
to something it will point at either another sequence,
or a floating-point number.

The header contains a reference count, the length of
the sequence, and some storage allocation info designed
to make it easier to append, prepend and concatenate
without necessarily having to copy the whole sequence
to a bigger area in memory.

Regards,
     Rob Craig
     Rapid Deployment Software

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu