Types

new topic     » goto parent     » topic index » view thread      » older message » newer message

Ralf Nieuwenhuijsen:
>puts(1, "It seems /"TEXT/" is an positive integer\n")
[...]
>This program will crash, unless you change the type definition to:
[...]

    It'll also crash if you don't change the forward slashes to backslashes.
:)
That "True/False condition must be an atom" thing did drive me crazy for
awhile too, though.  Kinda like figuring out when to use "k" and when to use
'k' in comparisons.  I'm beginning to get the hang of that part though.
(yay!)

Ad Rienks:
>if compare(string, {}) = 0 then
[...]
>if not find(string[n], "0123456789.")
[...]
>Hope this helps

   Yep!  That's even better than the (if not find( string[n],
{'0','1','2','3','4','5','6','7','8','9','.'} ) then) answer I finally came
up with.  There's one more place I should use "" instead of ' ' !  :)
Also found the necessity to check for null-strings.  Was letting me have
rectangles with only half of one coordinate like "[ 43 ]" instead of "[ 43
24  87  140 ]"

>IMO a better solution would be to reprogram the type definition as a
>function, that can be inside a loop, checking for good input.

   Actually that's the way I'm using these.  Not to check upon assigning,
but to check before I assign the data, so I can ensure that my complex
sequences are properly structured.  Guess I declared 'em as types just
because.  That's the way I think of 'em, types of data that you can build
big complex stuff out of.  Booleans, Numbers, Strings, Arrays, Dictionarys,
etc..  Maybe it's just a QBasic habit.  Seems right somehow, though...since
they're only verifying the validity of the data instead of manipulating it.
I dunno..

(In case you're wondering, I'm on my 3rd different approach at working on
some routines for PDF files now.  Complex beasts, they are....)

Arthur Adamson:
>        Rob, dictionaries, trees, etc would require considerably less space
>if there was a data type, useable in sequences, one byte instead of 4, to
>hold characters.
>        Perhaps bit twiddling can be used instead but it gets tedious and
>difficult.
>        Or have I overlooked another way?

      I've thought about that a bit myself, especially for string
manipulation.  Then I realized that a lot of character sets now use two-byte
characters.  (Unicode?)  And from what I understand, (disclaimer:  I read
this in a book somewhere) the 32-bit data bus in 386dxs and up is actually
quicker and more space efficient with 4-byte chunks than single bytes.
Every memory operation gets/puts 4 bytes anyway, so if you only want one the
CPU has to specify which and 'mask out' the others.  Of course, then there's
caches and pipelines and prefetch queues that vary from one processor to the
next to counter that..  So maybe it could be done, but I think it'd turn out
less optimal than it looks unless you special tuned it for each individual
CPU/Bus/Memory configuration.  That could get tedious and difficult too.
      And of course then someone would want word-sized types...  :)

Falkon

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu