gewoon.iemand wrote:
> Hi
>
> I'm implementing a LISP interpreter in JAVA. I have made a structure
[...]
> However, I'm running into a problem when I parse quoted lists. I could
> enter '(aVariable 1 2 3) or '(aFunction 1 2 3). When it gets parsed,
> the parser cannot know whether its a variable or a functor. I could
> also enter '(1 2 3 4), and the first element is neither.
>
> How should I deal with this? Is my implementation wrong and should I
> make the determination of whether to treat the first element as a
> symbol, functor or constant at run time, when a list is evaluated?
For this thing, you should translate '(1 2 3) into (quote 1 2 3).
However, it seems like you're missing the difference between
functions and macros entirely, given the question I snipped below
about SETQ. Are you writing a Lisp without macros?
--
Randall Randall <·······@randallsquared.com>
"Randall Randall" <·······@randallsquared.com> wrote in message
·················@alt.athenanews.com...
>
> For this thing, you should translate '(1 2 3) into (quote 1 2 3).
Not quite,
'(a b c) => (quote (a b c))
'a => (quote a)
'(a) -> (quote (a))
--
Geoff
Geoffrey Summerhayes wrote:
> "Randall Randall" <·······@randallsquared.com> wrote in message
> ·················@alt.athenanews.com...
>
>>For this thing, you should translate '(1 2 3) into (quote 1 2 3).
>
>
> Not quite,
>
> '(a b c) => (quote (a b c))
> 'a => (quote a)
> '(a) -> (quote (a))
>
Quite right. I plead sleepiness. :)
--
Randall Randall
In article <···························@posting.google.com>,
·············@gmail.com (gewoon.iemand) wrote:
> > For this thing, you should translate '(1 2 3) into (quote 1 2 3).
> > However, it seems like you're missing the difference between
> > functions and macros entirely, given the question I snipped below
> > about SETQ. Are you writing a Lisp without macros?
>
> You hit the nail right on the head, thanks. I hadn't really looked
> into macros and thougt of getting some basic functions working before
> doing anything fancy. Turns out macros are really important and I need
> a bit of investigating and change my implementation.
You also need to handle special operators, which are analogous to the
basic syntactic forms in other programming languages.
--
Barry Margolin, ······@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***