Re: [Chicken-users] how to unintern a symbol

2015-02-02 Thread Peter Bex
On Mon, Feb 02, 2015 at 11:34:05AM -0800, Dan Leslie wrote:
 
 Is that a function composition function I spy?
 I wasn't aware of such a thing in R5RS or R7RS, is it a chicken
 extension or a part of one of the Unity libraries?

It's a CHICKEN extension :)
There's also compose for when the functions accept/return more
than one value (o is a more efficient version for single arg).

Cheers,
Peter


signature.asc
Description: Digital signature
___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] how to unintern a symbol

2015-02-02 Thread cowan
Peter Bex scripsit:

 I wasn't aware of that CL behaviour.  IIUC that's actually conflating
 two different things: creating an uninterned symbol and unbinding
 an interned symbol.  I don't know of a way to unbind a variable through
 Scheme, but you can set the symbol's value slot (0) to C_SCHEME_UNBOUND
 in C.  This has to go with the warnings Don't try this at home, and
 this voids your warranty. :)

Actually, neither of those things is what CL `unintern` does, though
I can see how people might come to believe that.  What it does is to
remove an existing symbol from the symbol table.  The symbol maintains
its properties, including its value, but any future attempt to refer
to a symbol of the same name will create an entirely new object,
since lookup in the symbol table will fail (and of course this new
symbol is undefined).

To put things another way, `unintern` mutates its argument from
interned to uninterned.  It's a dangerous thing to do, because it
corrupts Scheme/Lisp read-write equivalence.

-- 
John Cowan  http://www.ccil.org/~cowanco...@ccil.org
If I have seen farther than others, it is because I am surrounded by dwarves.
--Murray Gell-Mann



___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] readline egg v2.0 feedback

2015-02-02 Thread Alexej Magura
Just pushed 3.0 out the door.  Please let me know if it isn't regnoized 
as the latest version and I'll bump it up to 3.1.


And let me know if yall come across any bugs.

It introduces the following toplevel commands:

 * ,rl-!!
 o Similar to Bash's /!!/, it evaluates the previous line.

 * ,rl-clh
 o Clears the history list for the current session

 * ,rl-savhist
 o Enables/disables saving history for the current session on exit

 * ,rl-rec
 o Enables/disables recording history for the current session

 * ,rl-rd
 o Reads a file's contents into the history list for the current
   session

 * ,rl-vi
 o sets the current editing mode to Vi emulation

 * ,rl-emacs
 o sets the current editing mode to Emacs emulation (the One True
   Editing-Mode) :P


The following functions have been added:

 * last-history-line
 o Returns the previous line in history as either a string or as-is

 * eval-last-history-line
 o The function behind /,rl-!!/

 * variables
 o dumps GNU Readline's variable state, such as what editing mode
   it is in and etc.

Most of the functions added by v2.0 have been removed in 3.0; this, 
unfortunately, includes the history searching functions.//However, the 
history searching functions will be added back again in the next 
(proper) release, which should be 3.1.


On 01/27/2015 11:10 AM, Evan Hanson wrote:

Hi Alexej,

My tuppence:

On 2015-01-27  4:01, Alexej Magura wrote:

I don't think I'll use the toplevel-command stuff after all: I can't promise
that the toplevel symbols readline exports won't get overwritten, and I'm
not entirely sure readline has any business providing private toplevel
symbols that are only applicable to it. It might confuse less-experienced
users*, for one, and for another there's the already mentioned possibility
of symbol collision, unless somebody more knowledge on this subject can
prove otherwise.

It's your call of course, but I'd urge you not to let this stop you if
you'd otherwise like to provide this feature. If all commands are
prefixed by rl, for example, the ease of use would outweight any risk
of conflicts, IMO. After all, extensions are expected to provide
commands; that's part of what the feature's there for. chicken-doc uses
it to great effect, for example.

Perhaps you could address the concern that users will mistake
readline-provided commands for builtins by adding a note that they come
from the readline egg to the commands' help strings?

Cheers,

Evan


___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] how to unintern a symbol

2015-02-02 Thread Peter Bex
On Mon, Feb 02, 2015 at 10:51:26AM -0700, Alexej Magura wrote:
 Does Chicken have anything comparable to Common Lisp's /unintern/? I
 thought that it might be under /##sys/, since other features present
 in Common Lisp, but absent in Chicken are available under that
 namespace, but it doesn't seem to be provided by that
 module/namespace.

There's string-uninterned-symbol, which is even documented, right
below gensym:
http://wiki.call-cc.org/man/4/Unit%20library#string-uninterned-symbol

If you have a symbol you want to unintern, you can get its string
and create an uninterned symbol from that:

(define unintern (o string-uninterned-symbol symbol-string))

(eq? (unintern 'foo) 'foo) = #f

Cheers,
Peter


signature.asc
Description: Digital signature
___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] how to unintern a symbol

2015-02-02 Thread Alexej Magura

AFAICT that just defines a symbol to itself, and only then if you run:

(define foo 1)
(define foo (unintern 'foo))
(eq? foo |foo|) = #t

But, as I said, that only defines 'foo as |foo|: it doesn't /undefine/ 
the symbol, and it needs to have side-effects, since the CL /unintern/ 
AFAIK effects the targeted package, or in our case module.


After uninterning /foo/, if I were to enter foo into the REPL to be 
evaluated, it would throw an unbound variable exception.


On 02/02/2015 11:31 AM, Peter Bex wrote:

On Mon, Feb 02, 2015 at 10:51:26AM -0700, Alexej Magura wrote:

Does Chicken have anything comparable to Common Lisp's /unintern/? I
thought that it might be under /##sys/, since other features present
in Common Lisp, but absent in Chicken are available under that
namespace, but it doesn't seem to be provided by that
module/namespace.

There's string-uninterned-symbol, which is even documented, right
below gensym:
http://wiki.call-cc.org/man/4/Unit%20library#string-uninterned-symbol

If you have a symbol you want to unintern, you can get its string
and create an uninterned symbol from that:

(define unintern (o string-uninterned-symbol symbol-string))

(eq? (unintern 'foo) 'foo) = #f

Cheers,
Peter


___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] how to unintern a symbol

2015-02-02 Thread Alexej Magura
Does Chicken have anything comparable to Common Lisp's /unintern/? I 
thought that it might be under /##sys/, since other features present in 
Common Lisp, but absent in Chicken are available under that namespace, 
but it doesn't seem to be provided by that module/namespace.
___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] how to unintern a symbol

2015-02-02 Thread Peter Bex
On Mon, Feb 02, 2015 at 11:55:12AM -0700, Alexej Magura wrote:
 AFAICT that just defines a symbol to itself, and only then if you run:
 
 (define foo 1)
 (define foo (unintern 'foo))
 (eq? foo |foo|) = #t
 
 But, as I said, that only defines 'foo as |foo|: it doesn't
 /undefine/ the symbol, and it needs to have side-effects, since the
 CL /unintern/ AFAIK effects the targeted package, or in our case
 module.
 
 After uninterning /foo/, if I were to enter foo into the REPL to be
 evaluated, it would throw an unbound variable exception.

I wasn't aware of that CL behaviour.  IIUC that's actually conflating
two different things: creating an uninterned symbol and unbinding
an interned symbol.  I don't know of a way to unbind a variable through
Scheme, but you can set the symbol's value slot (0) to C_SCHEME_UNBOUND
in C.  This has to go with the warnings Don't try this at home, and
this voids your warranty. :)

Cheers,
Peter


signature.asc
Description: Digital signature
___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] how to unintern a symbol

2015-02-02 Thread Dan Leslie

Is that a function composition function I spy?
I wasn't aware of such a thing in R5RS or R7RS, is it a chicken
extension or a part of one of the Unity libraries?

Thanks!
-Dan

Peter Bex pe...@more-magic.net writes:

 On Mon, Feb 02, 2015 at 10:51:26AM -0700, Alexej Magura wrote:
 Does Chicken have anything comparable to Common Lisp's /unintern/? I
 thought that it might be under /##sys/, since other features present
 in Common Lisp, but absent in Chicken are available under that
 namespace, but it doesn't seem to be provided by that
 module/namespace.

 There's string-uninterned-symbol, which is even documented, right
 below gensym:
 http://wiki.call-cc.org/man/4/Unit%20library#string-uninterned-symbol

 If you have a symbol you want to unintern, you can get its string
 and create an uninterned symbol from that:

 (define unintern (o string-uninterned-symbol symbol-string))

 (eq? (unintern 'foo) 'foo) = #f

 Cheers,
 Peter
 ___
 Chicken-users mailing list
 Chicken-users@nongnu.org
 https://lists.nongnu.org/mailman/listinfo/chicken-users

-- 
-Dan Leslie

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users