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



On Feb 14, 10:31 pm, Walter Banks <wal...@xxxxxxxxxxxxx> wrote:
kwikius wrote:
http://sourceforge.net/projects/quan

This is an interesting library. In effect you are saying applications
with things like

schedule_next_bit = current_time + (1/baud seconds);

if (weight >= (29 kilos + 5 grams)) { motor_off = true; }

In quan-0_2_0 this would look something like :

#include <quan/out/time.hpp>
#include <quan/reciprocal_time.hpp>
#include <quan/mass.hpp>

int main()
{
   typedef int serial_bit; // could add UDT bit type just faked here
   quan::reciprocal_time_<serial_bit>::per_s baud(200);
   quan::time::ms current_time(5);

   // This part is a good example of where custom semantics
   // would be useful
   // Note the float literal 1 in the expr (1./baud)

Some of this also shows up in the formal languages used in
PLC's.  For example the following grammar excerpt from
IEC 611311 defining time intervals.

interval       ::= days | hours | minutes | seconds | milliseconds
days           ::= fixed_point ('d')  hours
hours          ::= fixed_point ('h')  minutes
minutes        ::= fixed_point ('m')  seconds
seconds        ::= fixed_point ('s')  milliseconds
milliseconds   ::= fixed_point ('ms')

Interestingly C++ has proposals to have user defined literals, which
would allow initialisation of quan style quantities.
It might look something like :

  quan::time_<fixed_point>::ms operator('ms'){...}
  quan::time_<fixed_point>::s operator('s'){...}

IEC61131 has a limited number of application types but one of the better syntactically  thought out is time.

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).

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.

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 rbitrary 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.

regards
Andy Little







.