Article View: comp.lang.misc
Article #3977Re: Run-time Type Errors in Smalltalk
From: Norman Diamond
Date: Thu, 16 May 1991 01:18
Date: Thu, 16 May 1991 01:18
73 lines
3694 bytes
3694 bytes
In article <1991May15.141839.20603@daffy.cs.wisc.edu> quale@saavik.cs.wisc.edu (Douglas E. Quale) writes:
>In article <1991May13.082152.29294@tkou02.enet.dec.com> diamond@jit533.enet@tkou02.enet.dec.com (Norman Diamond) writes:
>>In article <1991May13.061520.11992@daffy.cs.wisc.edu> quale@khan.cs.wisc.edu (Douglas E. Quale) writes:
>>> XtVaGetValues(widget, XtNwidth, &width, XtNheight, &height, NULL);
>>>Unfortunately width and height are type XtArgVal which is a union which
>>>completely defeats any typechecking.
>>>This kind of type error CANNOT occur in a dynamically typed language.
>>
>>It could occur in a dynamically typed language, if the programmer can tell
>>the language to throw away tagging and type-checking. A competent programmer
>>would put a tag in the union type.
>
>In lisp, the most ``common'' dynamically typed language, you cannot throw away
>tagging.
I did say "if".
>But the fact is, this particular error does NOT occur in a dynamically typed
>language.
It could be made to occur. (Not that I would recommend it, of course.)
>If you or anyone else reading this is familiar with the X Toolkit Intrinsics
>and can see a way to avoid this problem I'd like to hear about it.
As I said, C is not an encouraging language for it, but a competent programmer
could put a tag in. (C allows a programmer to support dynamic typing, though
C itself does not support it, and in fact cumbersome syntax discourages it.)
typedef enum XtArgTag {
XtArgCaddr,
XtArgCharPtr,
XtArgLong,
XtArgIntPtr,
XtArgProcPtr,
} XtArgTag;
typedef union XtArgUnion {
caddr_t Caddr;
char *CharPtr;
long Long;
int *IntPtr;
proc *ProcPtr;
} XtArgUnion;
typedef struct XtArgVal {
XtArgTag Tag;
XtArgUnion Val;
} XtArgVal;
(I have tried to maintain the same style as the typename "XtArgVal".
My personal naming style conflicts with a Posix standard.)
>The designers of the Intrinsics found that C's static typing wasn't adequate
Of course.
>and built an unchecked dynamic type system on top of it.
That's their problem. And then they made life difficult for their clients.
>Now C's type system is very primitive, but I'm not certain
>that any static type system is flexible enough to handle this problem.
Pascal handled this problem -- and the syntax deliberately encouraged this
kind of checking.
>most promising approach might be a statically typed object oriented language.
Of course, object orientation is useful, but object orientation is really
orthogonal (or nearly so) to issues of static vs. dynamic typing.
--
Norman Diamond diamond@tkov50.enet.dec.com
If this were the company's opinion, I wouldn't be allowed to post it.
Permission is granted to feel this signature, but not to look at it.
Technical Details
Message-ID:
<1991May16.011804.21042@tkou02.enet.dec.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!pacbell.com!decwrl!pa.dec.com!jrdzzz.jrd.dec.com!tkou02.enet.dec.com!jit533!diamondReferences:
<1991May9.023313.28308@tkou02.enet.dec.com> <1991May13.061520.11992@daffy.cs.wisc.edu> <1991May13.082152.29294@tkou02.enet.dec.com> <1991May15.141839.20603@daffy.cs.wisc.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!pacbell.com!decwrl!pa.dec.com!jrdzzz.jrd.dec.com!tkou02.enet.dec.com!jit533!diamond From: diamond@jit533.swstokyo.dec.com (Norman Diamond) Newsgroups: comp.lang.misc Subject: Re: Run-time Type Errors in Smalltalk Message-ID: <1991May16.011804.21042@tkou02.enet.dec.com> Date: 16 May 91 01:18:04 GMT References: <1991May9.023313.28308@tkou02.enet.dec.com> <1991May13.061520.11992@daffy.cs.wisc.edu> <1991May13.082152.29294@tkou02.enet.dec.com> <1991May15.141839.20603@daffy.cs.wisc.edu> Sender: usenet@tkou02.enet.dec.com (USENET News System) Reply-To: diamond@jit533.enet@tkou02.enet.dec.com (Norman Diamond) Organization: Digital Equipment Corporation Japan , Tokyo Lines: 73