-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
predicate as an argument failed #16
Comments
@doug719 unlike in Scheme, in Shen you must wrap function names in (any? (function number?) [1 2 3]) |
But(any? number? [1 2 3])works ok on shen-cl.Why the difference?
On Wednesday, April 28, 2021, 9:07:30 AM MDT, Bruno Deferrari ***@***.***> wrote:
@doug719 unlike in Scheme, in Shen you must wrap function names in function when passing them as arguments.
(any? (function number?) [1 2 3])
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Bruno,
All of the schemes implementations and lisp implementations that I know of (including sbcl) exit on a CTRL-d. I would think that since shen is part of the lisp family, it would also allow this.
Regards,Doug
On Wednesday, April 28, 2021, 9:22:21 AM MDT, T.D. Telford ***@***.***> wrote:
But(any? number? [1 2 3])works ok on shen-cl.Why the difference?
On Wednesday, April 28, 2021, 9:07:30 AM MDT, Bruno Deferrari ***@***.***> wrote:
@doug719 unlike in Scheme, in Shen you must wrap function names in function when passing them as arguments.
(any? (function number?) [1 2 3])
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Because of the difference between Common Lisp and Scheme. Remember that in Shen symbols are self-quoting, so what you are trying to do when you don't wrap the name in In Common Lisp this works: (funcall '+ 1 2) but in Scheme this doesn't: (apply '+ '(1 2)) Now, if you try this in Shen with the type-checker enabled, you will notice that it doesn't catch it. That is a known issue and there are changes in the new spec that take care of that (but for now you will have to wait until that gets released). |
Hello Bruno,
Thanks for the explanation. The decision to quote args is ok for a cl based implementation, but not a good thing for a scheme based one. Having to enter (function number?) means that number? is not a first class function. I am used to first class functions in scheme.
Regards,Doug
On Wednesday, April 28, 2021, 9:52:27 AM MDT, Bruno Deferrari ***@***.***> wrote:
But(any? number? [1 2 3])works ok on shen-cl.Why the difference?
Because of the difference between Common Lisp and Scheme. Remember that in Shen symbols are self-quoting, so what you are trying to do when you don't wrap the name in function, is trying to apply a symbol instead of a function. Common Lisp allows that, Scheme doesn't, and in Shen it is undefined behavior unless you have the type checker enabled (and in that case you get a type error before the underlying platform even gets a chance to run the code).
In Common Lisp this works:
(funcall '+ 1 2)
but in Scheme this doesn't:
(apply '+ '(1 2))
Now, if you try this in Shen with the type-checker enabled, you will notice that it doesn't catch it. That is a known issue and there are changes in the new spec that take care of that (but for now you will have to wait until that gets released).
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Functions are first class in Shen, it is just that the syntax is different. When you write If you don't wrap the name in It works on Common Lisp because of what I explained above (it has nothing to do about how the code is compiled from Shen to Lisp or Scheme, both implementations share most of the compiler code), but about how Common Lisp behaves. Making the Common Lisp port not work like this would make it slower (because extra checks would be needed at runtime to prevent that behavior), in the same way that making other ports accept plain symbols as if they were functions would make them slower (because extra checks and lookups would be required at runtime). If you want a shorter version in Shen/Scheme, you can write |
Please read the "The Semantics of Symbols in Shen and Kl" section of this document: http://shenlanguage.org/shendoc.htm |
(any? number? [1 2 3])
Exception in unknown-location: attempt to apply non-procedure number?
This works on shen-cl
(define any?
_ [] -> false
F [X | Xs] -> (or (F X) (any? F Xs)))
The text was updated successfully, but these errors were encountered: