help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Union Type Object problem


From: Laurence Finston
Subject: Re: Union Type Object problem
Date: Thu, 12 Aug 2004 22:28:27 +0200
User-agent: IMHO/0.98.3+G (Webmail for Roxen)

-------------------
Hans Aberg wrote:
> 
> I think that those that work with TeX, and especially extensions of it,
> work in C, and not Pascal. For example, Omega does.
> 

Knuth programmed TeX and Metafont in Pascal using his 
"WEB System for Structured Programming".   
He published his code in _TeX: The Program_ and _METAFONT: The Program_ in the
series "Computers and Typesetting".
He and Silvio Levy developed CWEB, which is analogous to WEB, but for C and
C++.  I use CWEB for GNU 3DLDF. 

> 
> Other approaches might though be to write say a Metafont code to 3DLDF
> translator. You may even further admit the Metafont be included in segments
> of its own syntax, similar to the "extern" construct in C++.
> 

Someday, maybe.   There are many other tasks that I think are more important.

One of the most clever things about Metafont is that it can solve linear
equations and perform certain other operations with unknown quantities.  For
example, the following is valid MF code:

a = 2b;
b = .5c + 1;
c = 3;
show a;
--> 5 
show b;
--> 2.5 

Since `a', `b' and `c' aren't declared, MF considers them to be of type
`numeric'.  Operations on variables of other types with unknown values are
also allowed.

I plan to try to implement this in 3DLDF, but I have several more basic
features to implement, such as conditionals, loops, and macros.  First I have
to try to get my parser code to compile in under 5 minutes, though.

In MF, `path a' can be a `declaration' or a 
`boolean expression', e.g.,

path a; % `declaration'

if (path a) % `boolean expression'
...
fi

I'm not even going to try to implement this using Bison.  Maybe it would work,
but I think it's so likely not to, that I'm going to just use `is_path', etc.,
for the `boolean expressions' instead.

The same applies to the `=' operator, which is used for `equations' rather
than `assignments'.  In the following code:

transform t, u;
t = identity xscaled 2.3 yscaled 1.4 shifted (1, 2, 3);
u := t;
u = t;

The first `=' is equivalent to `:=' (the assignment operator) because this is
the first time a value is assigned to `t'.  The expression `u = t', on the
other hand, is an assertion. In this case, it's redundant, so MF will issue a
warning.

I'm not even going to try to implement this, and will use `==' to test for
equality instead.

Knuth emphasized that MF supported a declarative style of programming.  I've
run across this idea in other places as well, and I think that it hasn't
turned out to be such an important idea, after all.  I don't think there's
anything wrong with telling the computer what to do without beating about the
bush.  It doesn't mind.

Laurence



reply via email to

[Prev in Thread] Current Thread [Next in Thread]