From: Jeffrey Yasskin on
On Nov 23, 5:03 pm, "Andrei Alexandrescu (See Website For Email)"
<SeeWebsiteForEm...(a)erdani.org> wrote:
> > Of course, it is possible to define a language without UB and give it a
> > library that is "reach enough", but such languages are not what we would
> > call "system-programming languages" (try to find one).
>
> I think Modula-3 was system-level PL and also safe.

http://www.hpl.hp.com/techreports/Compaq-DEC/SRC-RR-52.pdf section 7
describes several features that can cause "unchecked runtime errors",
which look a lot like undefined behavior to me. These features are
segregated into "unsafe" modules, so one could see Modula-3 as two
languages: one system-level and unsafe, and one not system-level and
safe.

Jeffrey


--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: James Kanze on
Andrei Alexandrescu (See Website For Email) wrote:
> James Kanze wrote:
> > AJ wrote:
> >> One other serious legacy flaw in D (inherited from C/C++) is that it
> >> doesn't do away with undefined behavior. It's close, I think, but it's
> >> unfortunate that the holes aren't closed entirely.

> > No language manages to completely do away with undefined
> > behavior. Although C++ could surely do better in this regard;
> > there's a lot of unnecessary undefined behavior.

> (Late in the thread, but this cannot be let slip away.) Whatever
> happened to all languages that do manage to completely do away with
> undefined behavior?

Name one. I'm unaware of any.

> I'm asking this again: it would be best if we all refrained from "I'll
> qualify it on-demand" statements.

Well, I suppose that if you exclude support for threading, it
might be possible. But as far as I know, no language even comes
close. If nothing else, most older languages don't define the
case of insufficient ressources---some dialects of Lisp, for
example, say that in case of overflow in integral arithmetic,
they switch to an extended format, but they don't say what
happens when the extended format gets too big to fit in memory.
And most modern languages support threads, and I'm fairly
convinced that it is currently impossible to support threads
without undefined behavior---it would mean being able to
statically diagnose thread-safety.

And of course, any language which tries to support low level
programming must have some sort of undefined behavior, in order
to allow the language to access the machine itself. Ideally,
such places should be clearly marked---unsafe modules in the
Modula family, reinterpret_cast in C++ (but of course, C++
doesn't impose the use of reinterpret_cast to get undefined
behavior).

--
James Kanze (GABI Software) email:james.kanze(a)gmail.com
Conseils en informatique orient�e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S�mard, 78210 St.-Cyr-l'�cole, France, +33 (0)1 30 23 00 34


--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: kwikius on
Walter Bright wrote:
> Francis Glassborow wrote:
> > In article <ddydnXqDgMDef_jYnZ2dnUVZ_tidnZ2d(a)comcast.com>, Walter Bright
> > <walter(a)digitalmars-nospamm.com> writes
> >> Doing so would require:
> >>
> >> 1) adding user defined tokens
> >> 2) adding user defined syntax
> >
> > Did you ever write a Forth vocabulary? I have and among other things
> > implemented Logo on a Forth system.
>
> I've never done anything with Forth. I know next to nothing about it.
>
> If Forth is so powerful, why has it remained an obscure niche language?

C++:

std::cout << 1 * (2 + 3) / 4 ;

FORTH:

1 2 3 4 + * / .

I think !

regards
Andy Little


--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: James Kanze on
Andrei Alexandrescu (See Website For Email) wrote:

> I think Modula-3 was system-level PL and also safe.

I think it was about as safe as you could make a language, but
there are still several ways of getting undefined behavior in
Modula-3. The most obvious, of course, was to use the unsafe
keyword to specify that you wanted it. If I recall correctly,
accessing variables from several different threads outside of
the protected areas was also undefined behavior (but I may be
thinking of another language here---did Modula-3 even have
threads?). And on the implementations I'm aware of, so was
leaking memory---if the garbage collector ran out of memory, the
program crashed. (Although I'm not sure there either---the
language may have defined it that way. But I don't think so.)

The first is necessary in a system-level language. In modern
C++, the keyword reinterpret_cast could be considered more or
less like "unsafe" in Modula-3, except that it is much more
localized (and thus even safer). Regretfully, that's not the
only way of getting undefined behavior in C++ (and in fact, you
can do a reinterpret_cast without using the keyword).

--
James Kanze (GABI Software) email:james.kanze(a)gmail.com
Conseils en informatique orient�e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S�mard, 78210 St.-Cyr-l'�cole, France, +33 (0)1 30 23 00 34


--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: Walter Bright on
David Abrahams wrote:
>> Why aren't you programming in FORTH, then?
> All kindsa reasons.

Why do you prefer C++ over FORTH, if FORTH offers the power you want?

> Are you saying that you
> don't thoroughly understand why it failed to become mainstream?

Since I said I don't know FORTH, I can hardly claim to understand why it
failed.

--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]