🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #3606

RE: Type Systems and Dynamic Binding

#3606
From: cs450a03
Date: Fri, 19 Apr 1991 07:31
41 lines
1999 bytes
Joseph Allen    >
Me              >>
>>Let's say I was trying to implement a dynamically typed language in C.
>>(Of course, I wouldn't _really_ be that crazy  :-)  Let's say I wanted
>>to detect when, for instance, the addition of 2 integers produces an
>>invalid result.

>#define add(a,b) (a<0 && b<0 && a+b>=0 || a>=0 && b>=0 && a+b<0 ? error():a+b)

Ok, that should work, fairly generically I'd hope.

Now how do I generalize that to multiplication?

>I believe C is not really the problem.  What you want is for the
>processor to give an integer overflow signal so that the calculation
>can be repeated in floating point.  Unfortunately most (all?) don't.
> 
>Even in an interpretive language you'd have to:
> 
>	add
>	bov error
>	sub
>	bov error
>	mul
>	bov error

Interpretive??  That looks like _assembly_

Also note the existence of the new HP machines which have add and
branch semantics (and presumably multiply and branch).

I would hope that that's branch on overflow (though I haven't actually
asked -- if not you'd still have to execute two machine instructions
per HLL op).

Finally, note that a lot of time in assembly is spent in "routine
housekeeping" -- things like fetching and storing variable values, as
opposed to actually computing the results specified by the HLL.

Raul Rockwell
Technical Details
Message-ID: <19APR91.07311628@uc780.umd.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!emory!gatech!purdue!haven!ni.umd.edu!uc780.umd.edu!cs450a03
References: <3843@ssc-bee.ssc-vax.UUCP> <27313:Apr1623:30:0391@kramden.acf.nyu.edu> <17APR91.21054415@uc780.umd.edu> <1991Apr19.085233.2352@sbcs.sunysb.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!emory!gatech!purdue!haven!ni.umd.edu!uc780.umd.edu!cs450a03
From: cs450a03@uc780.umd.edu
Newsgroups: comp.lang.misc,comp.object
Subject: RE:  Type Systems and Dynamic Binding
Message-ID: <19APR91.07311628@uc780.umd.edu>
Date: 19 Apr 91 07:31:16 GMT
References: <3843@ssc-bee.ssc-vax.UUCP> <27313:Apr1623:30:0391@kramden.acf.nyu.edu> <17APR91.21054415@uc780.umd.edu> <1991Apr19.085233.2352@sbcs.sunysb.edu>
Sender: usenet@ni.umd.edu (USENET News System)
Organization: The University of Maryland University College
Lines: 41