unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Re: Is this a good use for "compile"
@ 2018-02-20 11:03 Mark Carter
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Carter @ 2018-02-20 11:03 UTC (permalink / raw)
  To: guile-user

: It is not clear to me how this will work.  First of all, compile may 
generate machine-dependent code.

That's OK. Generated code doesn't need to be saved. Formulae are 
compiled as needed.

: Second, how do you propose to evaluate my-cell-formulae ?

To evaluate a cell, I would call ((hash-ref my-cell-formula some-cell-ref))

Formulae are compiled to parameterless lambdas, which are stored in 
my-cell-formulae, So all I need to do is retrieve the relevant one, and 
execute it.




^ permalink raw reply	[flat|nested] 5+ messages in thread
* Is this a good use for "compile"
@ 2018-02-18 21:56 Mark Carter
  2018-02-19 17:30 ` Matt Wette
  2018-02-20  0:08 ` Vítor De Araújo
  0 siblings, 2 replies; 5+ messages in thread
From: Mark Carter @ 2018-02-18 21:56 UTC (permalink / raw)
  To: guile-user

New scheme user here.

Suppose I'm writing a spreadsheet. The user inputs a formula for a cell.

The plan is to use guile's peg parser to convert the formula into a 
lambda expression, which I then compile in order to speed-up subsequent 
processing.

So, suppose I convert the user's formula to a list, which turns out to 
be, for example: '(lambda (x) (+ x 13)) and compile it and save it in a 
formula table:

(hash-set! my-cell-formulae some-cell-ref (compile '(lambda (x) (+ x 13))))

So I can I expect a speed-up by having done the compile, as opposed to 
an eval?

I assume the answer is "yes", but I wanted to check.




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-02-20 11:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-20 11:03 Is this a good use for "compile" Mark Carter
  -- strict thread matches above, loose matches on Subject: below --
2018-02-18 21:56 Mark Carter
2018-02-19 17:30 ` Matt Wette
2018-02-20  0:08 ` Vítor De Araújo
2018-02-20  9:28   ` Mark Carter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).