[Top][All Lists]

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

Re: Newbie seeks guiding hands.

From: Martin Grabmueller
Subject: Re: Newbie seeks guiding hands.
Date: Thu, 15 Mar 2001 08:34:25 +0100

> From: Gary Benson <address@hidden>
> Date: Wed, 14 Mar 2001 17:20:12 +0000
> I'm almost completely new to both Guile and Scheme but I think they
> could be incredibly useful for a project I am involved in. I've got a
> couple of questions, one quick and one not so quick.
> The quick one: what is the difference between Scheme and Lisp?

Scheme is one dialect of the large family of Lisp languages.  Since
there are so many dialects of Lisp (Emacs Lisp, Common Lisp, T, and a
lot of others), it is difficult to answer your question precisely.
Maybe I can clear up the confusion by summarizing some properties of

Like the other Lisps, Scheme has an explicitly parenthesized prefix
notation, e.g. all procedure calls are enclosed in parentheses, where
the first element between the parentheses is the procedure to call,
and the remaining elements are the arguments.

In Scheme, all these elements are evaluated by the same rules, unlike
other Lisps, where the element in procedure position is evaluated by
different rules.

Also Scheme has static scoping, unlike Emacs Lisp but like Common Lisp

Procedures are first-class values, that means that it is possible to
create procedures on the fly, pass them as arguments to other
procedures or return them as function values.  I think this fact is
true for most Lisps.

And then Scheme has so-called first-class continuations.  I don't
think they are too important if you are just beginning to use Scheme,
so you should not care about them yet. (And besides: I don't think I
am able to explain them anyway -- they are pretty weird when you are
used to imperative programming languages).

Well, short question -- long answer...  if you have questions left,
feel free to ask more detailed questions.

[I didn't look at rcalc yet, but will try to give a few hints though]

> Secondly (and will probably resolve itself as I get more into Scheme), I
> don't know where to make the split between the C and Guile parts. Do I
> code each function as a separate scm file and do all the other stuff in
> C or do I rewrite the calculation engine in Scheme? 

It depends (of course): If you just want to add the ability to call
user-defined functions, you wouldn't have to write any Scheme code
yourself.  You could (for example) read a user's initialization file,
which defines functions. Then you would have to modify rcalc's
evaluator to call these functions when they appear in the input.

I image a scenario like this:

1. The user defines a function in her .rcalcrc
   (define (myfunc x)
     (* 2 x))

2. The user types in an expression, e.g
   1 + myfunc(2.4)

3. Your evaluator sees the call to `myfunc', and calls Guile to
   evaluate the call `(myfunc 2.4)'.

4. Guile returns the value `4.8'.

5. You evaluator calculates the rest of the expression and outputs

Another possibility would be to translate the input the user types
into Scheme expressions and then use Guile for evaluating them. That
would give you access to all the math functions already contained in
Guile. That would mean

3. The expression `1 + myfunc(2.4)' is translated to
   `(+ 1 (myfunc 2.4))'

4. Guile is used to calculate the value `5.8'.

5. Your application outputs the result.

>                                                      Applications that
> get to the point of embedding Guile tend to be massive already, which
> means that there is a hell of a lot of code to hunt through to find the
> relevant bits. It would probably take me a week, working solidly, to
> understand how something like Gnucash does its stuff. 

Note that Gnucash does more than using Guile just for simple
user-extension.  A lot of Gnucash is written in Scheme, so it maybe is
more like Emacs in that respect [Gnucash experts: Please correct me if
I'm wrong].

>                                                         [rcalc, when
> Guiled up, would probably make a nice example application for people who
> are in my position =) ]

I think that's a great idea.

> So what I really need is to be pointed in the right direction.

Hope that helps.  Please ask more if you're still puzzled.


reply via email to

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