Re: No exceptions?



paul c wrote:

This little puzzle is prompted by my distaste for exceptions. In a
language such as TTM Algebra, I wonder if they can be avoided in theory.

By 'avoided' I mean in the sense of avoiding direct language support
for them - an implementation might prefer to give ways to detect them
outside of specific language syntax. (Whether one wants to avoid
exceptions is a different question than whether one can avoid them.)

1) Syntax exceptions - An expression "x join y" might be a valid syntax
but one such as "x y" might not. An implementation could stipulate that
the reason it's not is because it is not an element of the domain for
expressions in the chosen language given a particular syntax. If we
have a way to test membership of such a domain, the syntax error could
be indicated by the value "false" given by a boolean function. (One
such way might be for all statements in a language to be treated as
propositions of a relation that describes some program unit.)

2) Semantic exceptions - "x join y" might be valid syntax but "x" might
be undefined, eg., there is no relation named "x".

However, the interpretation of a language could be defined such that the
mention of "x" without any collateral description stands for a relation
with no attributes. According to Hugh Darwen, there are (only) two such
relations, aka DEE and DUM and each must have a value (since each is a
relation). Although their values are hard to write down, he does say
(eg., at http://www.dbdebunk.com/page/page/1043196.htm) that DEE has one
tuple.

Within the TTM logical framework (and others), the Closed World
Assumption is a convention that says an unmentioned fact is false, ie.,
if the extension of a relation has no tuples, there are no propositions
that satisfy that relation's predicate. This seems to me to provide a
way around the non-determinism of "x join y" in isolation. Is it
reasonable for a language (again, in theory) to interpret the lack of an
extension for "x" as standing for DUM?

There could be operational exceptions such as "out of memory" but before
examining them, I'd appreciate comments on the above, especially as to
whether I'm not applying the CWA correctly.

The way to avoid exceptions is to treat them as compile-time errors.
.



Relevant Pages

  • Re: Implicit object constructor misinterpretation
    ... specified for the language that is being parsed. ... sub-set of the syntax for object literals. ... document that will teach anyone how to program with javascript. ... Consider the issue in your OP; you can speculate about "broken switch-case" or "not a constructor but a block of statements", but an examination of the spec shows that the observed behaviour corresponds with the specified behaviour, and explains the specified behaviour. ...
    (comp.lang.javascript)
  • Re: What is this code doing?
    ... Using the same syntax for most statements helps make the ... add, ebx); ... Instruction composition readability is another reason ... Jim Neil's Terse language). ...
    (alt.lang.asm)
  • Re: New bytecode assembly language to play with
    ... language that looks familiar, something I could probably figure out quite ... about a bit of superficial syntax here. ... The wheel has been reinvented several times. ... one that introduces new functionality, i.e. it's not just another way ...
    (comp.lang.misc)
  • Re: Working on new language
    ... I'll make sure to put some warts in the language:) ... syntax to me is misguided. ... So apart from the "so" keyword mentioned below I require ... It would be possible to separate arguments with commas, but the opens ...
    (comp.lang.misc)
  • Re: 10 ten things any good programmer can/has done?
    ... To quote Shriram Krishnamurthi, syntax ... > stress issues other than the surface syntax of some programming language. ... It means that more time has to be spend teaching the ...
    (comp.programming)