bcholmes: (Default)
[personal profile] bcholmes

Geek question:

What is the feature of a language that you consider "strong typing"? How does strong typing manifest itself (or not) in your favourite language or two?

(no subject)

Date: 2005-11-17 07:49 pm (UTC)
erik: A Chibi-style cartoon of me! (Default)
From: [personal profile] erik
(and in fact the last time I was using BASIC (which admittedly was Cro Magnon BASIC on I believe a Commodore PET), it would do what I think. I did it all the time, that's where I came up with the example. (if foo<128, foo=foo+128, endif. Ta da! Force caps!))

(no subject)

Date: 2005-11-17 07:59 pm (UTC)
erik: A Chibi-style cartoon of me! (Default)
From: [personal profile] erik
(sorry, make that -64, not +128. Been too long.)

(no subject)

Date: 2005-11-17 08:12 pm (UTC)
From: [identity profile] king-tirian.livejournal.com
Huh, every flavor of BASIC I ever used (including but not limited to QBASIC, QuickBASIC, and Visual Basic for DOS) was different and very strongly typed. "a"+1 would generate a syntax error. If you wanted to turn "a" into "b", you'd need to do CHR$(ASC(foo$)+1)), and if you wanted to turn "a" into "a1", you'd need to do foo$ + STR$(1).

(no subject)

Date: 2005-11-17 08:19 pm (UTC)
erik: A Chibi-style cartoon of me! (Default)
From: [personal profile] erik
interesting.
Either I'm misremembering the multiple layers of casting as in your example (it was 25 years ago, after all) or maybe I was doing peek-poke things to get around it...or Commodore BASIC was different.
All are equally likely.

I know that TUTOR (the language I worked in professionally in the 80s) and original K&R C both do it my way. C especially I remember transitioning from K&R to ANSI C and running up against the typing restrictions.

(no subject)

Date: 2005-12-03 08:47 pm (UTC)
From: [identity profile] http://users.livejournal.com/merle_/
You're probably just channelling old C memories, not BASIC.

char a = 'a';
a = a + 1;
/* a == 'b' now */


If your character is represented as a char/byte, then yes, incrementing it shifts the letter up. But if it's a string then it depends on how "+" is interpreted: either it will concatenate a "1", or, horrors, it will increment your pointer and...

Some BASICs let you work with character codes. Commodore BASIC had tons of poke/peek/call things that were basically invoking magic machine code, so you would probably have been passing char/byte values around.

Profile

bcholmes: (Default)
BC Holmes

February 2025

S M T W T F S
      1
2345678
9101112131415
16171819202122
2324252627 28 

Most Popular Tags

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Powered by Dreamwidth Studios