Re: LLVM was Results of the memswap() smackdown . . .





kwikius wrote:

On Feb 14, 10:31 pm, Walter Banks <wal...@xxxxxxxxxxxxx> wrote:

pump_on := curr_time + 4h6m29ms;

4h6m29ms is a constant that resolves itself back into a time offset.

I guess what we are looking at here is some sort of regular expression
(something which I hasten to add I am no expert on).

The C macro processor is essentially limited to simple text substitution
it isn't that hard to pre-process C with another program and parse the units
into constants. A regular expression parser in the pre-processor would have
many uses.

The problem that would need to be addressed for this to be useful
in a general purpose language is to also validate the context.

for example
time = 4h6m29ms; might be valid
length = 4h6m29ms; might not make a lot of sense.

It also opens other language requirements for example
casting
pump_on := curr_time + (time) 192; Cast an integer to time.

Ideally I guess you should have some means to translate an arbitrary
literal string, (presumably anything that starts with a numeric digit)
into an unambiguous function call.

The translation probably should happen earlier in pre-processing
or compiler phase. Useful tests could be done with the addition
of a different C pre-processor. To be anything other than a toy
serious work would needed to address the language implications.

For starters
1) Constants also need a valid context

2) Malcolm's comment " When you divide a distance by a time you
obtain a velocity, for instance. Divide by time again and you get an
acceleration. Multiply two distances to get an area or three to obtain a
volume."

Probably should be part of core language and almost certainly
would need some validation during translation.

3) User extensible (Andy Little)


To be generic that should presumably apply uniformly to what is built
in to C integer literals.

IOW 1UL should be a UDT literal that maps to an arbitrary user
defined function in a library rather than being built in.

hmm... Its quite useful, as once you remove fundamental types , all
you are left with is literals.

The translation ultimately is a literal but it is a literal that has default
units used by the system or application. (inches, seconds, radians)


Regards,

--
Walter Banks
Byte Craft Limited
Tel. (519) 888-6911
Fax (519) 746 6751
http://www.bytecraft.com
walter@xxxxxxxxxxxxx






.



Relevant Pages

  • Re: Queries and OO
    ... >> language other than the programming language. ... regular expression engine is encapsulated and does not pollute the ... FitNesse has such a design. ...
    (comp.object)
  • Re: Why want to do the things Lisp is best at?
    ... Each language typically has a "catch" ... My two favorite languages to program in are Forth and Lisp. ... An example of this was when I got to compiling the regular expression. ... (format t "KEYWORD: ~A~%" text))) ...
    (comp.lang.lisp)
  • Independent Study - Assistance?
    ... I have a question for the language experts, ... Given the concept of taking a regular expression and lifting from it ... the used symbols and sets, and using replacements for them, you should ... Mind you as far as my education goes, I have an Associate's of Science ...
    (comp.compilers)
  • Re: Programmers unpaid overtime.
    ... > relevant to this newsgroup, by removing all the irrelevant stuff. ... You've discussed the C language in this ng as the C ... But because incompetent programmers delight in pointing out other ... The regular expression is (if blanks only constitute white ...
    (comp.programming)
  • Re: case-sensitivity
    ... trivial pre-processor that turns your code with CAPITAL-AS-HIGHLIGHT ... into normal code before having it processed by the compiler. ... how come you ask this ad-hoc ... As for the ad-hocness of putting it in the language: ...
    (comp.lang.scheme)