1. Re: Structures & Receit when Registering
- Posted by Ralf Nieuwenhuijsen <nieuwen at XS4ALL.NL>
Jan 20, 1999
-
Last edited Jan 21, 1999
[Structures: My vote]
Although I wont be using Lucius' 'solution', due to the incompatibility of
scope problems, different algorithmic expressions, and not to forget
*speed*, I will second that structures make Euphoria cleaner.
Why ? You can easily see how the 'sequence' should be formed. Its
automatically checked withouth the need of a complex type check function. It
improves speed, and in those cases where we often do:
for index = 1 to length(list) do
item = list[index]
-- lots of calculations involving item
list[index] = item
end for
Things will become both more clear, and faster, because we lack the need of
the special trick I pull above.
(and possible errors with side-effect functions)
[Arrays]
Like structures, arrays should be possible. It is simply more clear. Often
we use sequences as arrays, with all possible risk of using our
coffee-machine to make soup. I mean, look at the code below:
[Example]
type byte (object x)
if integer(x) and x > -1 and x < 256 then
return 1
else
return 0
end if
end type -- I know it can be shorter, but: "return ..." doesnt
short-circuit.
-- With arrays (which require direct initialization), we could do this:
byte picture[100][100] = 0
-- Rather than:
type my_special_specific_type (object x)
if sequence (x) and length(x) = 100 then
for index = 1 to length(x) do
if not sequence (x[index]) or length(x[index]) != 100 then
return 0
else
for index2 = 1 to length(x[index]) do
if not byte (index2[index]) then
return 0
end if
end for
end if
end for
return 1
else
return 0
end if
end type
my_special_specific_type picture
picture = repeat (repeat(0, 100),100)
-- Off course we should be able to specify an argument the same way:
global function display_mysprite (byte picture[100][100], integer
pos[2])
display_image (pos, picture)
pos[x] = pos[x] + 1
return pos
end function
[Conclusion]
With arrays & structures & the module based scope rules, you can develop
huge programs in Euphoria easily, consisting of many libraries, with the end
program being as fast as C.
I figured, the whole stack-based system of Euphoria is pretty fast, when
used correctly. (when would we be jumping around more? In oo C++ or in
Euphoria's stack mechanism ?)
Calculations with 4 byte machine integers are generally faster than 1
byte calculations. And Eu's stack mechanism can not be much slower than C++
oo "lets jump around the code for an hour". So, where does the speed go ? It
leaks at two places:
1) Dynamic memory allocation: even when you *dont* need it. (arrays &
structures are sequences with a fixed structure)
2) Altough Euphoria is nice, the rest of the pc-world (windhoos, etc.)
is not. Speed is lost during conversion. Logicial and little we can do about
it, rather than just programming smart, and do more in Euphoria and use less
standard bios-interrupts, less windows-calls, etc. Is safer anyway.
[Registering]
Also, Robert a little question. When I register, is there any way to have an
official receit, a prove of purchase, or something I can print out ? (needed
for tax-related issues)
Ralf