Just to add my few cents worth to a couple of recent issues...

X<-1> = '' works exactly as it has been defined to work for the last 35
years!
One of the things about not (originally) having the concept of an SQL style
null item is that you cannot tell the difference between an empty list and a
list with one null entry.  It is trivial to program around this once you
recognise the problem.


X = '123' + '456' performs an arithmetic calculation.
This is absolutely fundamental to how UV/Udt work.  I have lost the original
mail that started this thread but I recall it was being blamed on a
particular release of UV.  If this didn't work, nothing would work so it
must be more subtle than that.

Although we think of UV Basic as being a typeless language, it isn't.  There
are actually around a dozen data types inside the product. All operators
look at the data they are working on and, where appropriate, transform it to
the correct type.  The addition operator (and all other arithmetic
operators) will try to convert character string data to numeric form.  If
the conversion is successful, the addition takes place.  If not, you get the
"non-numeric data where numeric required" message.

The entire product relies on this translation taking place.  For example, if
you ask a user to type in a number it will actually be stored as a character
string.  Each use of the data as a number will transform it.  Whilst this is
no problem if we only use the data infrequently, a loop that does the
conversion hundreds of thousands of times will do the conversion each time:

INPUT CT     (user types 1000000)
FOR I = 1 TO CT
....
NEXT CT

This will convert CT for every iteration of the loop.  It gets worse if you
use CT many times in the loop too.  For this reason, programmers sometimes
force a data conversion with the apparently pointless "add zero" statement:

INPUT CT     (user types 1000000)
CT = CT + 0
FOR I = 1 TO CT
....
NEXT CT

The extra statement takes CT as a string, adds 0 to it forcing a conversion
and stores it as a number.  The loop then goes faster.  I once worked on an
application where getting the data types optimised in this way made the
program go over 10000 times faster!


In my work I encounter many UV/Udt users and get to see many different
applications.  I find it amazing how little some programmers understand
about the product they are using.  The questions raised on this list are
sometimes so simple that it makes me wonder if the users concerned have
actually ever looked at the documentation or been on a training course.  By
way of a quick advert, my company (Ladybridge Systems) offer UV/Udt training
in the UK and parts of Europe.  IBM have courses that are delivered
worldwide (by us in the UK).  I know I have plugged it before but I strongly
recommend the UniVerse Internals course for those who really want to get a
deep understanding of how this system works.  Sadly, there is no equivalent
for Unidata.  The programming courses are great fun and address many issues
like the ones discussed above.


Martin Phillips
Ladybridge Systems
17b Coldstream Lane, Hardingstone, Northampton NN4 6DB
+44-(0)1604-709200

_______________________________________________
u2-users mailing list
[EMAIL PROTECTED]
http://www.oliver.com/mailman/listinfo/u2-users

Reply via email to