-
Notifications
You must be signed in to change notification settings - Fork 586
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
[Lisp] WIP Overhaul #2387
[Lisp] WIP Overhaul #2387
Conversation
2946869
to
c2cc58e
Compare
Hey, this looks very good so far! I'm not a Lisp expert, but I can try to provide some answers here.
It is impossible to know whether the first thing will be called as a function or not, without running the code. But I think the best solution would be to always highlight the first thing as a function name, unless the list is quoted, or the first thing is a string or a number.
(setq x (quote (1 2)))
(print (eval (append (list '+) x))) ; prints 3 Here
Yes, (defun f (a) (+ a 1))
(setq quote #'f)
(print (eval (append '(funcall) (quote (quote 4))))) ; prints 5
The
There are few more, for characters and multidimensional arrays, but I think some compilers introduce even more non-standard interpretations. I'm not sure what the specification says about it. Regarding this PR, I'm a bit confused by the changes. What is the point of keeping the list of all built-in functions, while you instructed the highlighter to color every first element of a list as a function name? |
|
Thanks. This is helpful. I'll roll with that.
Interesting. I think I will use the same scope for
Your example is a little scary. I don't really want to detect Also, if
I think I understand what they do now (h/t Samuel's link and CMU), but not necessarily what they are. I'm using a variety of scopes depending on the behavior of each one (minus a few that aren't done), but I can imagine someone being upset that the
The scopes are subtly different (and obv depending on color scheme may look exactly the same) between built-in functions and things we assume are user-created functions. In my color scheme, for instance, built-ins are the same color but italic. |
Just like seemlingy everyone else I have no experience with Lisp, but I will provide some general comments/advice after I took a really quick look at the changes and the comments in here.
Since
Depending on how likely this is, it may actually be a "good enough" heuristic to roll with. At least until someone complains about it. +1 on using
LGTM. Most of these have punctuation character (the numeric ones and |
I have never used Lisp either, but I would use the |
Note that other functional languages, such as Haskell and Clojure, already scope |
Haha. I don't notice this because I have my active bracket settings bold/glow/fg-color (rather than underline). That's a very valid point you bring up. I don't expect it would be that unnerving in the circumstances, but ymmv.
No objection. My code highlighting right now is very function-heavy.
Agreed.
Yeah, but how many special functions do we need to do special things for? I'll start to add the handled and unhandled bits to OP for reference. |
94f0c30
to
cb96eb4
Compare
I think most of these changes are very welcome. See my PR for changes related to the scoping of In terms of scoping I would advise against trying to special syntax I really like the idea of highlighting functions/macros in s-expressions, but I'm not sure if it's a good idea due to how common false positives will be, regardless I think it's more important to highlight the things below than random function calls. Concrete additions:
(let ((def 32)
dec)
normal code here)
|
@s-clerc Thanks! Sorry I missed @-ing you with the first set of changes. I'll probably end up having questions about some of the specifics when I dig into them. |
No problem! Honestly you’re doing me a huge favour with all this work as it is. |
; bracket line below in the first column is highlighted in my proposal
(let ((test x))
(do-whatever) ; bracket missing here, we want a marker here ideally
(let ((test y))
(do-nothing)) ; but theoretically, this could be contained within the form above To achieve an at-end bracket warning, we'd need to consider both line-breaks and indentation to guess where people meant the form to end. |
I'm not sure what the state of this is, or how much of an improvement this is over the existing lisp syntax. That said, if we are at a point where it provides some significant improvements, we could treat it like we did Haskell in #2225 and merge the current state, which will hopefully get feedback from other users and allow future improvements. It all sort of depends on if this is a superset of the existing syntax, or if there are significant regressions. |
My personal non-Lisp-programmer opinion:
Everything else I'm aware of is in a better or equivalent state. |
There seems to be a bug in the stray bracket detection; in this file, on line 300 LispWIP will mark the last bracket as a stray which is incorrect and a regression as no stray is reported by Lisp. |
Closing as superseded by #3896 as everything of this PR is included and has evolved further. |
I don't really know what I'm doing with Lisp, so someone else will have to vet this.
One particularly scary thing is "How do I know if the first thing in some parentheses is a function or not?" Is it always triggered by the
'()
? If not, what are each of these:(a b c)
,( a b c)
,("foo")
,(1 2)
?I also do not really understand
#
stuff. Like#c(4 -8)
is a complex number, right? But there is also#(1 2 3)
that is a vector or list... and it's immutable? Maybe?/cc @gighmmpiob @JellyWX @rotty @samuel-jimenez
For the
Packages
veterans:'
, which apparently tells Lisp not to execute a group or symbol?complex
(a type) versus the#c
above, a specific complex number.#
for vector to#2A
for a two-dimensional array#\
which is a characterStatus
.
s or digits\
-escaping symbol chars works|
-delimiting a whole symbol works|
-delimiting portions of a symbol works&
-word annotations&
-word annotations aredef*
-specific#\
#o
,#b
,#x
,#c
(kind of),#_r
#'
#,
,#.
#+
,#-
#_=
,#_#
#(
#_a
#:
#s
#p
`
`
allows you to use,
where you couldn't before (instead,,
highlights everywhere)quote
let
format
string mini-language~%
, etc~D
,~,,,,:D
, etc.