Posted by Nick at 1/14/2001 10:52 PM EST
Student on team #240, Mach V, from Jefferson Monroe High School and Visteon.
Here’s a thought. Say I were to input a standard 1 byte analog device (y). But instead of setting the variable (x) as a byte I change it to, let’s say a nib (4 bits). I am curious to the value x. Would the program give a simple error? Or would x be assigned a value? If y = 255 then x = 15? If y = 0 then x = 0? Here’s the real challenge if y = 240 (binary 11110000) does x = 15 or x = 0? If anyone has the slightest clue please let me know.
Posted by Matt Leese at 1/14/2001 11:56 PM EST
Other on team #73, Tigerbolt, from Edison Technical HS and Alstom & Rochester Institute of Technology.
In Reply to: Programming question
Posted by Nick on 1/14/2001 10:52 PM EST:
I believe that PBasic should emit an error (it is strongly typed, no?). That’s just my initial impression. You can get at the high-nibble and low-nibble of a byte if you so wish (high nibble being first four bits and low nibble being the last four bits). The same works for any datatype. I don’t remember the exact syntax off hand but it should be in the manual and there’s at least an example of it in the default code using bits.
Matt
Posted by Joe Johnson at 1/15/2001 7:00 AM EST
Engineer on team #47, Chief Delphi, from Pontiac Central High School and Delphi Automotive Systems.
In Reply to: Re: Programming question
Posted by Matt Leese on 1/14/2001 11:56 PM EST:
Matt, what PBASIC are YOU programming in? I am not a programmer by training so I may be all wet here, but I don’t think that PBASIC meets the definition of a strongly typed language.
As to what will happen if you set a variable that is not as wide as the thing you are setting it equal to, the sad truth is that everything to the left of the bits PBASIC needs is ignored!
SO…
X VAR nib
X = 16 'FYI 16 is 0001000 in binary
’ X will be set to 0 because the right 4 bits are 0000
Joe J.
Posted by Matt Leese at 1/15/2001 7:18 AM EST
Other on team #73, Tigerbolt, from Edison Technical HS and Alstom & Rochester Institute of Technology.
In Reply to: Strongly typed?
Posted by Joe Johnson on 1/15/2001 7:00 AM EST:
I’ll be honest. I haven’t touched it since last year (yet). I honestly never did the whole “put a value into the wrong type of variable” so this was more or less my guess. Apparently I guessed wrong. And for PBasic to be strongly typed it’d just have to not allow this type of situation. Basically not allow it to compile. Part of the reason I said it was strongly typed is that BASICs in general tend to be (more so then say C).
Matt
Posted by Joe Johnson at 1/15/2001 8:10 PM EST
Engineer on team #47, Chief Delphi, from Pontiac Central High School and Delphi Automotive Systems.
In Reply to: Re: Strongly typed?
Posted by Matt Leese on 1/15/2001 7:18 AM EST:
I have heard C described as a language for consening
adults because it assumes that the programmer knows
what he/she is doing and lets them set a structure
equal to a bit or a character or a logical.
PBASIC is similar in this regard in that it does not do
a whole lot of checking to give the user messages along
the lines of “do you really mean that?”
Programmers Beware!
Joe J.
Posted by Matt Leese at 1/15/2001 8:35 PM EST
Other on team #73, Tigerbolt, from Edison Technical HS and Alstom & Rochester Institute of Technology.
In Reply to: PBASIC – A language for consenting adults?
Posted by Joe Johnson on 1/15/2001 8:10 PM EST:
PBasic isn’t nearly as bad as C is though. But seriously, PBasic is a pretty easy language to learn. There’s not enough complexity there to be difficult
When you can do pointer-pointers in PBasic then I’ll consider it hard. And BTW, if C is for consenting adults then I must’ve been breaking the law learning it at 13…
Matt
Posted by Lloyd Burns at 1/15/2001 1:14 AM EST
Other on team #188, Woburn Robotics, from Woburn Collegiate and Canada 3000, ScotiaBank, Royal Bank Financial.
In Reply to: Programming question
Posted by Nick on 1/14/2001 10:52 PM EST:
If you wany the low nibble of byte “ANALOG1”, why not define “LSNANA1” as the low nibble of ANALOG1? Then if ANALOG1 = 0xA5 = B’10100101’, LSNANA1 = 0x5 = B’0101’, and you have no processing to do; the compiler does it all !