🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #3576

Re: Dynamic typing (part 3)

#3576
From: Dr A. N. Walker
Date: Tue, 16 Apr 1991 15:11
48 lines
2349 bytes
In article <1991Apr9.021700.2688@neon.Stanford.EDU>
brm@neon.Stanford.EDU (Brian R. Murphy) writes:

>My complaint about statically typed languages is that I _can't_ do
>some things in them that I _do_ in dynamically typed languages (such
>as Lisp).

	But your examples are perfectly OK in *some* statically typed
languages, which suggests that it's a problem with your specific languages
rather than with typing.

>	    For example, I can't I write a function which returns
>either a boolean or an integer in a complex way.

	proc fred = union (bool, int): if random < 0.5 then true else 1 fi;
  # eg, #
	print ("found a" + case fred in (bool): " bool" out "n int" esac)

>						   I can't write my own
>Y combinator.

	Pass.

>		I can't write a function which allows either a sequence
>of functions which range over numbers or a sequence of numbers as an
>argument.

	mode integer = union (int, long int),
	     fraction = struct (integer numerator, denominator),
	     number = union (integer, real, long real, fraction);
	proc (number) number bert = (skip);

	proc jim = (union ([] proc (number) number, [] number) a) void: (skip);
  # eg, #
	jim (1); jim (pi); jim ((1, pi)); jim ((bert, bert, bert));
		# no guarantees that these will compile without casts! #

What you are asking for is almost the standard "print" specification,

	proc print = ([] union (proc (ref file) void, int, real, etc)): ...,

which is defined that way so that you can print arbitrary sequences of
printable things, like arrays, strings, numbers, interleaved with
procedures like "newline" that move around the output without printing.

-- 
Andy Walker, Maths Dept., Nott'm Univ., UK.
anw@maths.nott.ac.uk
Technical Details
Message-ID: <1991Apr16.151100.7221@maths.nott.ac.uk>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!elroy.jpl.nasa.gov!swrinde!mips!spool.mu.edu!uunet!mcsun!ukc!warwick!nott-cs!piaggio!anw
References: <3073:Mar2820:38:5191@kramden.acf.nyu.edu> <1991Apr1.010526.26781@neon.Stanford.EDU> <boehm.670539603@siria> <1991Apr9.021700.2688@neon.Stanford.EDU>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!elroy.jpl.nasa.gov!swrinde!mips!spool.mu.edu!uunet!mcsun!ukc!warwick!nott-cs!piaggio!anw
From: anw@maths.nott.ac.uk (Dr A. N. Walker)
Newsgroups: comp.lang.misc
Subject: Re: Dynamic typing (part 3)
Message-ID: <1991Apr16.151100.7221@maths.nott.ac.uk>
Date: 16 Apr 91 15:11:00 GMT
References: <3073:Mar2820:38:5191@kramden.acf.nyu.edu> <1991Apr1.010526.26781@neon.Stanford.EDU> <boehm.670539603@siria> <1991Apr9.021700.2688@neon.Stanford.EDU>
Reply-To: anw@maths.nott.ac.uk (Dr A. N. Walker)
Organization: Maths Dept., Nott'm Univ., UK.
Lines: 48