Google Groups Home
Help | Sign in
Colon commands
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  13 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Evans Winner  
View profile  
 More options Jan 13 2008, 5:08 am
Newsgroups: comp.lang.lisp
From: Evans Winner <tho...@timbral.net>
Date: Sun, 13 Jan 2008 03:08:52 -0700
Local: Sun, Jan 13 2008 5:08 am
Subject: Colon commands
Some research seems to indicate that at least OpenMCL, ACL and LispWorks
maybe have some kind of facility that allows the definition of commands
that can be used at the repl that look like--

:command

--or maybe--

:command arg1 [arg2 ... argn]

I know at least clisp has something like this at least in the debugger.
Is this is standard Common Lisp facility?  (There is also a comma command
syntax in scsh, i know, as well.)

Sorry if the question is vague; i don't know if there is an established
term for this.  I can't find a reference in the Hyperspec.  In any case,
it might be nice to be able to define commands like that for convenience
at the repl.  Can it be done?--or is there a reason it's a bad idea?


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rainer Joswig  
View profile  
 More options Jan 13 2008, 5:36 am
Newsgroups: comp.lang.lisp
From: Rainer Joswig <jos...@lisp.de>
Date: Sun, 13 Jan 2008 11:36:55 +0100
Local: Sun, Jan 13 2008 5:36 am
Subject: Re: Colon commands
In article <86r6gmca17....@timbral.net>,
 Evans Winner <tho...@timbral.net> wrote:

There is no reason it is a bad idea. Most Lisp systems have something
like that.
There is no standard for this. Everybody does it somehow differently.
There is not even a widely used portable one for the terminal - besides
what you get when you use SLIME + Emacs. McCLIM comes with a
window-based listener.

One simple type of command is when the REPL allows you
to get rid of the top-level parentheses. LispWorks
does that for example for functions with arguments.
You can type at the LispWorks listener:

 CL-USER 7 > compile-file "foo.lisp"
 ;;; Compiling file foo.lisp ...

Useful REPLs have quite a few services:

* command loops, break loops, commands, command tables
* completion for commands, lisp symbols and arguments
* history (redo)
* dribble
* error handling, restarts, processes
* debugger, inspector, trace, step
* line editing
* help

and some more


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Maciej Katafiasz  
View profile  
 More options Jan 13 2008, 9:07 am
Newsgroups: comp.lang.lisp
From: Maciej Katafiasz <mathr...@gmail.com>
Date: Sun, 13 Jan 2008 06:07:14 -0800 (PST)
Local: Sun, Jan 13 2008 9:07 am
Subject: Re: Colon commands
On Jan 13, 11:36 am, Rainer Joswig <jos...@lisp.de> wrote:

> Useful REPLs have quite a few services:

[snip]
> * dribble

What's that?

Cheers,
Maciej


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Zach Beane  
View profile  
 More options Jan 13 2008, 11:16 am
Newsgroups: comp.lang.lisp
From: Zach Beane <x...@xach.com>
Date: Sun, 13 Jan 2008 11:16:38 -0500
Local: Sun, Jan 13 2008 11:16 am
Subject: Re: Colon commands

Maciej Katafiasz <mathr...@gmail.com> writes:
> On Jan 13, 11:36 am, Rainer Joswig <jos...@lisp.de> wrote:
>> Useful REPLs have quite a few services:

> [snip]
>> * dribble

> What's that?

http://www.lispworks.com/documentation/HyperSpec/Body/f_dribbl.htm has
information about the standard dribble.

Zach


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pascal Bourguignon  
View profile  
 More options Jan 13 2008, 2:31 pm
Newsgroups: comp.lang.lisp
From: Pascal Bourguignon <p...@informatimago.com>
Date: Sun, 13 Jan 2008 20:31:18 +0100
Local: Sun, Jan 13 2008 2:31 pm
Subject: Re: Colon commands

Evans Winner <tho...@timbral.net> writes:
> Some research seems to indicate that at least OpenMCL, ACL and LispWorks
> maybe have some kind of facility that allows the definition of commands
> that can be used at the repl that look like--

> :command

> --or maybe--

> :command arg1 [arg2 ... argn]

> I know at least clisp has something like this at least in the debugger.
> Is this is standard Common Lisp facility?  (There is also a comma command
> syntax in scsh, i know, as well.)

It is not standard.  The role of comma is defined only in the context
of backquote.

> Sorry if the question is vague; i don't know if there is an established
> term for this.  I can't find a reference in the Hyperspec.  In any case,
> it might be nice to be able to define commands like that for convenience
> at the repl.  Can it be done?--or is there a reason it's a bad idea?

Note that at least in Allegro Common Lisp, the character prefixing
these commands (both user defined and system provided) is
configurable.

In the case of clisp, there's no prefix character for user commands.
They can be any symbol, not just keywords:

C/USER[23]> (com.informatimago.pjb::define-user-commands (:fecha date user1::dote)
                "Interactive commands"
              "Prints the date."
              (com.informatimago.common-lisp.interactive:date))
:FECHA
C/USER[24]> :fecha
2008-01-13 20:24:57
C/USER[25]> date
2008-01-13 20:25:00
C/USER[26]> user1::dote
2008-01-13 20:25:04

For clisp users:

To define more easily user commands in clisp, I use these macros:

(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter *user-command-groups* (make-hash-table :test (function equal)))
  (defun ensure-list (item) (if (listp item) item (list item))))

;;(setf custom:*user-commands* nil)

(defun generate-user-commands ()
  (setf custom:*user-commands*
        (let ((commands '()))
          (maphash
           (lambda (category command-list)
             (dolist (command  command-list)
               (destructuring-bind (names docstring body) command
                 (push (coerce
                        (let ((vfun (gensym)))
                          `(lambda ()
                             (flet ((,vfun () ,@body))
                               (list
                                ,(format nil "~%~:@(~{~S ~}~) ~A" names docstring)
                                ,@(mapcar (lambda (name)
                                            `(cons ,(format nil "~(~S~)" name)
                                                   (function ,vfun)))
                                          names)))))
                        'function) commands)))
             (push (coerce
                    `(lambda () (list ,(format nil "~2%~A:" category)))
                    'function) commands))
           *user-command-groups*)
          commands))
  (values))

(defmacro define-user-commands (names category docstring &body body)
  (let ((names (ensure-list names)))
    `(let ((entry (find ',names  (gethash ',category *user-command-groups* '())
                        :test (function equal)
                        :key (function first))))
       (if entry
           (setf (second entry) ',docstring
                 (third  entry) ',body)
           (push (list ',names ',docstring ',body)
                 (gethash ',category *user-command-groups* '())))
       (generate-user-commands)
       ',(first names))))

(defun delete-user-command (name)
  (maphash (lambda (category commands)
             (setf commands (delete name commands
                                    :test (function member)
                                    :key (function first)))
             (if commands
                 (setf (gethash category *user-command-groups*) commands)
                 (remhash category *user-command-groups*)))
            *user-command-groups*)
  (generate-user-commands))

Refer to the Implementation Notes for teh description of custom:*user-commands*.

--
__Pascal Bourguignon__                     http://www.informatimago.com/

Nobody can fix the economy.  Nobody can be trusted with their finger
on the button.  Nobody's perfect.  VOTE FOR NOBODY.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rainer Joswig  
View profile  
(2 users)  More options Jan 13 2008, 3:00 pm
Newsgroups: comp.lang.lisp
From: Rainer Joswig <jos...@lisp.de>
Date: Sun, 13 Jan 2008 21:00:38 +0100
Local: Sun, Jan 13 2008 3:00 pm
Subject: Re: Colon commands
In article <87r6gl5xq1....@thalassa.informatimago.com>,
 Pascal Bourguignon <p...@informatimago.com> wrote:

The comma is used by some Lisp REPLs. They have REPL modes: command preferred and
Form preferred (plus command only, Lisp only). In command-preferred mode,
the comma is used to prefix Lisp code, so that it is not
interpreted as commands. It is called a 'form dispatch character'.
The 'Form preferred mode' has a command dispatch character, a colon.
Some CLIM listener may use this.

 Form preferred:

 :Copy File foo.lisp foo1.lisp    is interpreted as a command
 copy                             is interpreted as a variable

 Command preferred:

 Copy File foo.lisp foo1.lisp    is interpreted as a command
 ,copy                           is interpreted as a variable

...


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Evans Winner  
View profile  
 More options Jan 13 2008, 5:25 pm
Newsgroups: comp.lang.lisp
From: Evans Winner <tho...@timbral.net>
Date: Sun, 13 Jan 2008 15:25:10 -0700
Local: Sun, Jan 13 2008 5:25 pm
Subject: Re: Colon commands

Rainer Joswig <jos...@lisp.de> writes:

    The comma is used by some Lisp REPLs. They have REPL modes: command
    preferred and Form preferred (plus command only, Lisp only).  In
    command-preferred mode, the comma is used to prefix Lisp code, so
    that it is not interpreted as commands.  It is called a 'form
    dispatch character'.

But this is not part of standard CL, right?  Is there a portable way to
do it?  (It sounds like something one could create with a reader-macro,
but `:' and `,' as are a lot of other characters, so it might be
inherently un-portable...?)


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rainer Joswig  
View profile  
(1 user)  More options Jan 13 2008, 5:32 pm
Newsgroups: comp.lang.lisp
From: Rainer Joswig <jos...@lisp.de>
Date: Sun, 13 Jan 2008 23:32:20 +0100
Local: Sun, Jan 13 2008 5:32 pm
Subject: Re: Colon commands
In article <86zlv9bby1....@timbral.net>,
 Evans Winner <tho...@timbral.net> wrote:

> Rainer Joswig <jos...@lisp.de> writes:

>     The comma is used by some Lisp REPLs. They have REPL modes: command
>     preferred and Form preferred (plus command only, Lisp only).  In
>     command-preferred mode, the comma is used to prefix Lisp code, so
>     that it is not interpreted as commands.  It is called a 'form
>     dispatch character'.

> But this is not part of standard CL, right?

Right, REPLs are not an extensive part of the standard. Very
little about the REPL user interface is said in the standard.

>  Is there a portable way to
> do it?  (It sounds like something one could create with a reader-macro,
> but `:' and `,' as are a lot of other characters, so it might be
> inherently un-portable...?)

Either you use one of the portable REPLs (I've mentioned SLIME
and McCLIM) or you have to use the implementation specific
stuff.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Evans Winner  
View profile  
 More options Jan 13 2008, 6:56 pm
Newsgroups: comp.lang.lisp
From: Evans Winner <tho...@timbral.net>
Date: Sun, 13 Jan 2008 16:56:18 -0700
Local: Sun, Jan 13 2008 6:56 pm
Subject: Re: Colon commands

Rainer Joswig <jos...@lisp.de> writes:

    Either you use one of the portable REPLs (I've mentioned SLIME
    and McCLIM) or you have to use the implementation specific
    stuff.

Ok.  Got it.  Thank you.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kent M Pitman  
View profile  
(1 user)  More options Jan 13 2008, 9:24 pm
Newsgroups: comp.lang.lisp
From: Kent M Pitman <pit...@nhplace.com>
Date: 13 Jan 2008 21:24:20 -0500
Local: Sun, Jan 13 2008 9:24 pm
Subject: Re: Colon commands

Evans Winner <tho...@timbral.net> writes:
> Some research seems to indicate that at least OpenMCL, ACL and LispWorks
> maybe have some kind of facility that allows the definition of commands
> that can be used at the repl that look like--

> :command

> --or maybe--

> :command arg1 [arg2 ... argn]

> I know at least clisp has something like this at least in the debugger.
> Is this is standard Common Lisp facility?  (There is also a comma command
> syntax in scsh, i know, as well.)

The use of colon has nothing to do with the ":" as far as I know.

Because keywords are bound to themselves, there is little point in a REPL
to asking their value.  Consequently, I believe the reason :foo was chosen
as a command is that one can just call READ normally and see if the result
was a keyword, and in that case just treat it as a command.  Consider the
following two interactions for LispWorks, for example.  In the first case,
there is no leading colon; in the second case, no colon at all.

  CL-USER 1 > keyword:?

  :bug-form <subject> &key <filename>
           Print out a bug report form, optionally to a file.
  :get <variable> <command identifier>
           Get a command from the history list and put it in a variable.
  :help    Produce this list.
  :his &optional <n1> <n2>
           List the command history, optionally the last n1 or range n1 to n2.
  :redo &optional <command identifier>
           Redo a previous command, identified by its number or a substring.
  :use <new form> <old form> &optional <command identifier>
           Redo command after replacing old form with new form.
  NIL

  CL-USER 1 > #.(intern "?" "KEYWORD")

  :bug-form <subject> &key <filename>
           Print out a bug report form, optionally to a file.
  :get <variable> <command identifier>
           Get a command from the history list and put it in a variable.
  :help    Produce this list.
  :his &optional <n1> <n2>
           List the command history, optionally the last n1 or range n1 to n2.
  :redo &optional <command identifier>
           Redo a previous command, identified by its number or a substring.
  :use <new form> <old form> &optional <command identifier>
           Redo command after replacing old form with new form.
  NIL

> Sorry if the question is vague; i don't know if there is an established
> term for this.  I can't find a reference in the Hyperspec.  In any case,
> it might be nice to be able to define commands like that for convenience
> at the repl.  Can it be done?--or is there a reason it's a bad idea?

You can easily write your own REPL, but there is no very strict
spec-defined REPL ... Just some general conventions about how variables
like -, +, ++, +++, *, etc. are intended to be managed _if_ there is a
REPL at all.

The main reason there is not a total convention about this is that in some
implementations there may be a desire to use other conventions.

On Symbolics Genera, : _was_ an escape into a command parser, in the case
of :form-preferred prompting, where everything was a form unless prefixed
by a parser.  In :form-only mode, there was no such escape.  In :command-only
mode, you were always in command mode.  In :command-preferred mode, I believe
you didn't need a prefix for commands but could use , to get to forms.  In
the Symbolics debugger, single keystrokes (characters with various "bucky
bits" set, what one would now call modifier bits) were co-opted as command
accelerators.

In LispWorks, there are two debugger modes--one that is command line based
and uses these commands, but another that is a GUI debugger and does not.

Common Lisp has tried to encourage uniformity where possible but not to tie
the hands of implementations wanting to do better.  A spec that required
keywords to behave a certain way might be seen as one that required
implementations to have old-fashioned interfaces.  Or such was the fear,
as I recall.

There was pressure to remove the "environment functions/commands" from the
spec altogether.  But I'm glad they weren't removed.  Feeble as the conformance
requirements are for commands like ROOM, DESCRIBE, DISASSEMBLE, ED,
DOCUMENTATION, etc., it's nice to have hinted to implementations that these
are things that matter to a community of users.  And they create touch points
for people who are new to an implementation to get a foothold.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pascal J. Bourguignon  
View profile  
(1 user)  More options Jan 14 2008, 8:20 am
Newsgroups: comp.lang.lisp
From: p...@anevia.com (Pascal J. Bourguignon)
Date: Mon, 14 Jan 2008 14:20:19 +0100
Local: Mon, Jan 14 2008 8:20 am
Subject: Re: Colon commands

Evans Winner <tho...@timbral.net> writes:
> Rainer Joswig <jos...@lisp.de> writes:

>     The comma is used by some Lisp REPLs. They have REPL modes: command
>     preferred and Form preferred (plus command only, Lisp only).  In
>     command-preferred mode, the comma is used to prefix Lisp code, so
>     that it is not interpreted as commands.  It is called a 'form
>     dispatch character'.

> But this is not part of standard CL, right?  Is there a portable way to
> do it?  (It sounds like something one could create with a reader-macro,
> but `:' and `,' as are a lot of other characters, so it might be
> inherently un-portable...?)

You can implement REPLs portably, even REPLs implementing strange
syntaxes for characters like #\: and #\,.

But indeed, the REPL provided by the implementations are rather
implementation dependent, because they are rather underspecified by
the standard. You cannot provide the same kind of features in a REPL
based on punch card than in a REPL based on 3D virtual reality
interfaces, much less on mind reading devices.

--
__Pascal Bourguignon__
mailto:pascal.bourguig...@anevia.com
http://www.anevia.com


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Raffael Cavallaro  
View profile  
 More options Jan 14 2008, 10:59 am
Newsgroups: comp.lang.lisp
From: Raffael Cavallaro <raffaelcavallaro@pas-d'espam-s'il-vous-plait-mac.com>
Date: Mon, 14 Jan 2008 10:59:33 -0500
Local: Mon, Jan 14 2008 10:59 am
Subject: Re: Colon commands
On 2008-01-14 08:20:19 -0500, p...@anevia.com (Pascal J. Bourguignon) said:

> You cannot provide the same kind of features in a REPL
> based on punch card than in a REPL based on 3D virtual reality
> interfaces, much less on mind reading devices.

I believe this last is more properly called a RESPL
;^)

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Steven M. Haflich  
View profile  
 More options Jan 16 2008, 8:40 pm
Newsgroups: comp.lang.lisp
From: "Steven M. Haflich" <s...@alum.mit.edu>
Date: Wed, 16 Jan 2008 17:40:42 -0800
Local: Wed, Jan 16 2008 8:40 pm
Subject: Re: Colon commands

Kent M Pitman wrote:
>> Some research seems to indicate that at least OpenMCL, ACL and LispWorks
> On Symbolics Genera, : _was_ an escape into a command parser, in the case
> of :form-preferred prompting, where everything was a form unless prefixed
> by a parser.

As a point of history, I believe I was the one responsible for this use
of the colon char in a repl.  More than 20 years ago several of us at
Franz were discussing how to provide various useful repl functionality
such as load, compile-file, and abort without requiring the user to
enter forms.  We were thrashing what syntax to use when I suggested the
leading colon char.  I can remember part of the message being "When was
the last time you needed to evaluate a keyword?"

Nonetheless, I'm pretty sure the LispM command repl had already used
colon in some sort of similar context, although with different
machinery.  I have never pondered how the inheritance of this feature
passed from one implementation to another, and am disinterested in
doing it now.

> Common Lisp has tried to encourage uniformity where possible but not to tie
> the hands of implementations wanting to do better.

One could argue that Common Lisp has tried to discourage doing better
(in the language development sense) by failing to tie the hands of
implementations, but if I presented that question casual readers would
think me a troll...

(Do implementations have hands?)


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google