Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!zen.net.uk!dedekind.zen.co.uk!aioe.org!.POSTED!not-for-mail From: "Rod Pemberton" Newsgroups: comp.lang.forth,comp.lang.misc Subject: Typing, was [Re: Metrics on stack usage] Date: Wed, 24 Sep 2014 21:07:45 -0400 Organization: Aioe.org NNTP Server Lines: 61 Message-ID: References: <541855C0.2558D27D@bytecraft.com> <2014Sep23.180149@mips.complang.tuwien.ac.at> <5422b163$0$15834$e4fe514c@dreader35.news.xs4all.nl> <7xk34swrjl.fsf@ruckus.brouhaha.com> NNTP-Posting-Host: CNsg4fVcCsvs3UaOgZtQCw.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Opera Mail/12.16 (Linux) X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.forth:33552 comp.lang.misc:2693 On Wed, 24 Sep 2014 19:02:38 -0400, Paul Rubin wrote: > albert@spenarnc.xs4all.nl (Albert van der Horst) writes: >> Crashing is certainly the best way to enforce that a bug be fixed. > > The worst property of untyped languages like C and Forth is that > they don't crash when there's a type error. Forth is untyped. Although, someone other than me, perhaps Ms. Rather, could argue that characters, integer cells, floating point, and control-flow returns are effectively typed in Forth by the correct usage of Forth words (AKA procedures or functions in other languages) ... I.e., if you don't use the wrong word, you won't access the wrong type. Of course, there is no differentation between a cell and an address of a cell (or pointer) in Forth ... ;-) C is typed. You have to use casts or (ab)use the valid type conversion rules to not get warnings for usage of incompatible types or type punning with most C compilers. Or, you can not enable warnings or disregard them, but most do enable warnings and also take care of them. So, do you mean strongly typed instead of weakly typed here? ... Strong typing is generally bad, IMO. If the language doesn't have a way to access an object or item via different methods, then there is no way to do so. You can't override the type system in strongly typed languages, nor can you extend the language to allow you to do so. But, you might need to do so. The problem here is that the language designer may not have thought of or come across all needed conversions. So, they didn't implement something. Think unions in C which allow multiple types to access the same storage, or pointer to integer casts and conversions in C which are needed to allow storage of addresses and their use as in the original type later on. Weakly typed languages allow you to use a item or object which is normally used in one manner, to be used in another. A common situation is where a pointer or address is used to fetch another repeatedly, such as some implementations of linked-lists and interpreters. This violates the type system of most languages. Dereferencing or fetching an item changes the type of the item or object. I.e., "pointer to type" or "address of object" when dereferenced or fetched becomes "type" or "object". Sometimes you want "pointer to type" or "address of object" to remain "pointer to type" or "address of object" when fetched or dereferenced. > They can corrupt data or memory and the program keeps running. There are generally no runtime checks in many languages due to slowness. You bring up typing frequently, Paul. So, I added comp.lang.misc. Rod Pemberton