Re: A speakable (kind of) SUO-KIF ?
- From: "martinobal" <martinobal@xxxxxxxxx>
- Date: 16 Jan 2007 15:59:23 -0800
Pascal Bourguignon wrote:
Indeed. The reader macro function has the stream, and can do whatever
it wants with it, and return 0 or 1 forms. (eg the reader macro for ;
reads till the end of line and returns 0 forms, so we skip the
comment).
Cool :)
[...]
I would like to have a chat client that does't let you delete anything
you type, but instead it lets you refer to those things you want to
change, and replace them, as you would do in speech.
Using readline?
I don't know... it would have no backspace deletion or special keys, it
would just wait for an "enter" keystroke, maybe not even that, but an
"enter" keyword, and then read the input. It may let you see a preview
of the line you typed, with the corrections applied, before it actually
sends it, so that you can abort the operation, but that's about it. The
point is not to be visually comfortable, but to imitate speech as
closely as possible. Is "readline" fit for this task?
No, in lisp, you don't have to define a function before "using it".
You just need to have defined it before you actually call it. For
example, when you read the source of fact, the function fact is not
defined yet, so we cannot know that it takes only 1 argument, so the
code reading it, or even the DEFUN macro couldn't know how many
arguments to pass to the recursive call to fact itself.
Now I'm confused. You seem to say that you need to define the function
first, but then you can't define it because the DEFUN macro can't do
it. But you gave me the following piece of code:
#: defun fact n : if = 0 n : 1 * n fact 1 - n :
Which is basically what I have in mind, except that I wrote "end"
instead of ":". Wouldn't this work?
This returns a s-exp like:
(SETF (SYMBOL-VALUE 'FACT)
(FUNCTION (LAMBDA (X) (IF (ZEROP X) 1 (* X (FACT (1- X)))))))
;; (actually it might be more complex (eg keeping the source, the
;; lambda list, the documentation around, etc, but that's essentially
;; what DEFUN does.)
then eval works on it. When evaluating the lambda function, the
function FACT is still not defined, so how could we know that fact
takes only one argument, (1- x), if there wasn't the parenthesis to
tell us?
Well, I guess the reader macro takes "defun fact n:" and so it knows
that fact is unary. I was temped to say that "end"/":" act as the
parens, but this is a simple example (tail recursion, right?). If FACT
weren't at the end of the definition, but in the middle, it would be
harder to parse, so I guess what I said above is necessary. Another
possibilty is to "declare" FACT (its name and number of arguments) in a
previous sentence. I'm ok with that. Yet another possibility would be
to actually insert the parens when you need to (if you want to use a
function before declaring or defining it). I mean the parens should
still be available and work as usual, that's why I chose another
keyword, such as "end" instead of ")", as a delimiter for the macro.
(defun f (x) (if (evenp x) (f (truncate x 2)) (g (1- x))))
;; Here, g is not defined, but it's used by f. How can we know how
;; many arguments g takes?
Same here. Just define g or at least declare it before using it for
defining f. That pretty much what we do in speech. Before using a new
concept, we usually give, at least, a sketch of what it means. Or just
use the parens("open" and "close" keywords).
I would write:
For 1 argument:
open mymacro f x end ... close
For 2 args:
open mymacro f x y end ...close
For 3 args (no more args left):
open mymacro f x y ... close
The question is when you read: f 3 4 5
how do you know where to close the argument list of f? What is the
number of arguments f takes in that scope? How can you know that at
read-time?
I'm assuming that f is already defined, so the reader macro knows it
has (at most) three arguments, so it accepts whatever arguments come
after it until it finds an "end" or until the 3 args are completed.
Notice I say whatever arguments, not whatever atoms. The parsing,it
seems, has to begin with the unary functions followed by atoms, to
create conses possibly used as arguments for other unary functions .
Then, binary functions followed by atoms and/or these first-level
conses, an so on... In short, (bracket-free) Polish notation whenever
possible, the "end" delimiter for variadic functions when the number of
args they are taking is lower than their maximum, and parens as an
option (for postponed declaration or just to add some redundancy).
I skimmed through that page and it seems like a way to evaluate the
code as you type it, instead of waiting until you hit enter. Is that
correct? I don't think I would need that kind of capability.
Yes. You'd need it even worse. But it's simply not possible: you
just cannot execute the code you are reading, before compiling it and
before deploying it in its run-time environment.
I don't want to do that. As I said, what I want is *less* interactive
than the usual IDE, not more. In fact I don't want and IDE, just a way
to "talk" (by keyword) to an inference engine in real time, as a first
step towards actually *speaking* to it. If I have to input a
definition/declaration in the previous sentence (so it gets compiled
and all) before I use it, that's ok.
Otherwise I don't understand this paragraph. Anyway, I don't see a
big problem here, since I would ultimately have to pick an
implementation (and even a lisp dialect, for that matter).
Here I said something silly. I want a *language*, not just an
implementation. It should be usable for human communication, even in
the absence of computers. But again, I think you are referring to
features I wouldn't need.
Regards,
-Martin
.
- Follow-Ups:
- Re: A speakable (kind of) SUO-KIF ?
- From: Pascal Bourguignon
- Re: A speakable (kind of) SUO-KIF ?
- References:
- A speakable (kind of) SUO-KIF ?
- From: martinobal
- Re: A speakable (kind of) SUO-KIF ?
- From: Ken Tilton
- Re: A speakable (kind of) SUO-KIF ?
- From: martinobal
- Re: A speakable (kind of) SUO-KIF ?
- From: Arne Knut Roev
- Re: A speakable (kind of) SUO-KIF ?
- From: Pascal Bourguignon
- Re: A speakable (kind of) SUO-KIF ?
- From: martinobal
- Re: A speakable (kind of) SUO-KIF ?
- From: Pascal Bourguignon
- Re: A speakable (kind of) SUO-KIF ?
- From: Pascal Bourguignon
- Re: A speakable (kind of) SUO-KIF ?
- From: martinobal
- Re: A speakable (kind of) SUO-KIF ?
- From: Pascal Bourguignon
- A speakable (kind of) SUO-KIF ?
- Prev by Date: Re: Who was that masked Open Source fairy? [was Re: McCLIM 0.9.4 "Orthodox New Year" released!]
- Next by Date: Re: MRP Systems and Lisp
- Previous by thread: Re: A speakable (kind of) SUO-KIF ?
- Next by thread: Re: A speakable (kind of) SUO-KIF ?
- Index(es):
Relevant Pages
|