I am now paying for them. Argg. The binding routine packs away so much state, 
it will
be very hard to unravel ;( Particularly to provide a "functional" routine, yet 
keep all
the existing code working...

I'm inclined to blow away all the existing wrapping code. This will break Felix
for at least a week while I do the unravelling ;(

Interestingly .. the building and saving of the unbound symbol tables which is 
now
working may have been useless ;( This is because the existing code
already creates a bound table from the assembly stream (which is a problem
because I have already done half that job building the unbound symbol tables).

I really only need to call that code early and cache the result to save 
reparsing
and binding the standard library :)

With the new structure it would be possible (if I got it working) to make
that process faster by only rebuilding the tables for changed files,
but it hardly seems worth while: whilst working on the library rebuilding
the whole thing is slow, but not nearly as slow as testing. For normal
application programming it will never happen :)

BTW: interesting Ocaml problem. I have a routine called "cached_computation"
which saves the result of any calculation to disk, and reloads it next time
the calculation has to be done (I mean, the same calculation in a different
call to the compiler). This routine automatically checks one time stamp
and it also saves the Felix version info and checks it hasn't changed
on loading.

What it doesn't do is check for computation specific invariants.
For example, the symbol tables of a library change when any
of the include files of the library change. The "time stamp" check
only works for one file. If the include files are saved in the
cached data, a validation routine can easily go off and check
the time stamps .. but only AFTER the file is loaded.

The problem is we get really ugly code:

  let result = cached_computation "filename" func in
  let result = if validate result then result else
    let result = func () in
    save_to_disk result;
   result
 in

which is really bad because the "save_to_disk" function is currently
internal to "cached_computation". The obvious solution is:

let result = cached_computation "filename" func validate in

that is, to pass the validator into the cached computation.. the problem is
I don't think it can be done!

The reason is that "func" is known internally to be type

        unit -> 'a

and validate has to have type

        'a -> bool

Internally, we call Marshal.write on the 'a produced by func,
and that works because it accepts any type as an argument.

But our validate does not. It only accepts a particular type.
So clearly it can't be called on the result of either the function
or the Marshal read until they have been "cast" to their actual type,
and that only happens *outside* the cached_computation function!

The only way I can think of to fix this is to pass a record:

        type 'a gen_and_val = { generator: unit -> 'a; validator:'a -> bool; }

since now the 'a is the same for both functions.


--
john skaller
skal...@users.sourceforge.net





------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to