freenode/#lisp - IRC Chatlog
Search
15:56:09
Xach
trafaret1: the following form is evaluated at read time and the return value is used as the result from the reader.
15:57:59
Xach
many read macros start with #, are optionally followed by a numeric argument, and concluded with a single character that is associated with the behavior. #+, #-, #=, #., #< are a few examples.
16:13:35
moldybits
trafaret1: (loop :repeat 5 :collect (random 10)) => (7 9 8 0 5) (loop :repeat 5 :collect #.(random 10)) => (6 6 6 6 6)
16:15:32
trafaret1
If I get your right it's just like evaluate the expression and that results send into another expression to evaluate
16:18:14
trafaret1
(loop :repeat 5 :collect #.(random 10)) => (6 6 6 6 6) for me it's strange behaviour
16:19:15
fivo
I am using slime with company. I installed the following plugin https://github.com/anwyn/slime-company
16:19:33
moldybits
trafaret1: (loop :repeat 5 :collect #.(random 10)) becomes (loop :repeat 5 :collect 6) after it's been read.
16:19:38
fivo
Before I used the plugin company also completed local varaibles which it doesn't anymore.
16:21:38
moldybits
most things are evaluated only once, but this exampled used a loop so it is more pronounced
16:22:47
_death
the first thing that happens when you load a file or enter text at the repl is that the reader gets called with the stream of characters.. the reader operates according to a readtable.. by default, this readtable contains an entry for the '#' character that dispatches further according to the following character(s).. if the character '.' is encountered, the reader gets called recursively to read the next object.. after the object is
16:22:48
_death
read, the reader will evaluate it, and return with the value, and the next step will commence
16:24:48
moldybits
(let ((x 42)) (+ 1 x)) => 43 (let ((x 42)) #.(+ 1 x)) => error: variable X unbound
16:29:56
_death
for example entering #.#.(list 'list ''list '''list) will have the reader call itself twice, the final result being (list 'list), which in turn will be passed to the evaluator, resulting in (list)
16:32:28
moldybits
(lol ((x 42)) (+ 1 x)) => Compile-time error: illegal function call ((x 42)) (lol ((x 42)) #.(+ 1 x)) error: variable X unbound
16:33:24
moldybits
the problem is not with the let, but that #.(+ 1 x) is evaluated before the let (or nonexistant lol) is evaluated
16:37:11
moldybits
(defparameter x 42) (let ((x 5)) (print #.x)) <- this prints 42 even when `sbcl --load file.lisp'. that surprises me.
16:38:57
_death
the defparameter form gets read and evaluated, then the let form gets read and evaluated
17:10:41
flip768
I know that I can have (AND whitespace ... whitespace) in the rule, but then I need to explicitly do something to not return them
17:41:53
pfdietz
The top level forms are processed before the following forms are read. Things like (in-package ...) would not work if that weren't the case.
17:43:12
specbot
Processing of Top Level Forms: http://www.lispworks.com/reference/HyperSpec/Body/03_bca.htm
17:46:51
pfdietz
trafaret1: a common idiom for sharp-dot is putting constant variable values into CASE forms.
17:48:20
_death
pfdietz: I wrote about it a long time ago.. "One minor thing" paragraph @ https://github.com/death/consix/wiki/Postmortem---a-bit-of-postmortem-never-hurt-anyone!
17:50:56
pfdietz
I think that would be fine, as long as the defconstant appears in another file. That way, the form will have been evaluated by the time its value is needed.
17:54:28
pfdietz
Macro definition is fine. "If a defmacro form appears as a top level form, the compiler must store the macro definition at compile time, so that occurrences of the macro later on in the file can be expanded correctly. "
18:58:43
ark
fivo: I have slime-company working with completion in the repl lisp files. Here's my config: https://gitlab.com/_ark_/dotfiles/blob/5967f8c68ea7fbe4b5c852b134fb14404b4564ff/emacs.d/init.el#L997-1002
19:20:50
fiddlerwoaroof
fivo, ark: I use slime-company too, but in my experience, it can be a pain getting it to work
19:47:06
scymtym
i guess a feature request here https://github.com/wallyqs/org-ruby would be appropriate, but getting off topic
22:18:55
alexanderbarbosa
what mainstream language is the most lispy? thinking of changing careers and taking programming seriously... :D
22:45:51
no-defun-allowed
alexanderbarbosa: none, wouldn't be mainstream according to your dichotomy then
22:46:37
no-defun-allowed
not every day you hear someone call a language ALGOL-y or APL-y for example
22:46:39
alexanderbarbosa
no-defun-allowed: some @ emacs said golang and javascript es6, whatever it is
22:47:51
no-defun-allowed
since neither is homoiconic, has macros, the scoping system of Lisp we all know and love, dynamic strong typing, CLOS, etc
22:48:29
alexanderbarbosa
please, dont make my end of day bad... i want a light in end of the tunnel :D
22:49:43
no-defun-allowed
why do you need a language that superficially is derived from lisp that isn't lisp?
22:51:57
aeth
Go is basically a better-C, and is basically the opposite of Lisp. Like with C, you have a plain style without a lot of abstraction. micro-readability, basically. If you see a random 10 LoC, you should know what's going on. On the other hand, with Lisps you tend to aim for macro-readability, with a lot of abstractions.
22:52:20
aeth
(* of course Go has GC, so it will fail to attract anyone who is still on C and didn't switch to Java in the 90s)
22:52:54
aeth
Also, notably, Go has no generics, whereas in Lisp, you have to try pretty hard to get specifics.
22:53:03
alexanderbarbosa
p_l: because after some, lazy I might add, there no seems to have that much of Lisp jobs
22:53:12
p_l
aeth: ehh, it seems to attract a lot of people due to not being associated with certain issues of early java
22:53:42
p_l
alexanderbarbosa: there's a saying in Poland: "Let's eat shit, billions of flies can't be wrong"
22:54:03
p_l
But for all practical purposes, I'd say it's easier than ever to end up using lisp in any random job
22:54:51
p_l
for JVM environments, you have clojure and ABCL (and a bunch of Schemes, some with AOT compilation). We now have "age of containers" and people are less picky about deps. Microservices actually help too, because you can write your bit in CL
22:55:19
p_l
but in reality, the number one case for using CL in a job? Have your own company and do projects for clients as a whole
22:55:38
p_l
because believe me, a non-IT company probably won't care about what language the project is in
22:56:18
p_l
drew crampsie used to talk about doing lots of intranet sites for various companies, none of which cared they were in Common Lisp
22:56:32
aeth
CL's #1 modern strength is probably in generation of other languages. e.g. https://edicl.github.io/cl-who/ for HTML
22:58:33
p_l
30 minutes ago, it was for Ada2012 (with SPARK where possible) to generate code for hard realtime systems on ARINC 653 platforms
23:01:22
p_l
might want to build a library for source maps, but it's a bit more annoying when your language technically doesn't use text for source code
23:10:00
alexanderbarbosa
weird, why would someone use a language to translate to yet another one...
23:15:27
no-defun-allowed
Clojure is also weird and exposes gory JVM semantics, so DON'T USE IT for the love of jmc.
23:18:06
alexanderbarbosa
no-defun-allowed: so its either CL/Scheme or forget about Lisp... it seems
23:18:17
no-defun-allowed
But basically if you want Lisp semantics, you want Lisp. I can't really advise you on any close-enough solutions.
23:22:12
p_l
as for compiling to another language... that's the effect of web browsers having only JS available
23:24:21
p_l
no-defun-allowed: and it's a bit less important than people think other than for purity
23:28:05
no-defun-allowed
i don't usually post r/lispmemes content here but this summarises all the other problems: https://www.reddit.com/r/LispMemes/comments/bp6pbm/psst_hey_clojure_fans/eunol2o/
23:29:28
aeth
alexanderbarbosa: Even if all of the languages are well designed, what you don't get unless you use code generation is a uniform syntax, and your brain context switching between 5-10 different syntaxes in a few minutes is how you make simple typos.
23:30:00
aeth
But once you put something in s-expression form, what you can start doing is using macros on top of the generated language as if you were writing macros for Lisp itself.
23:34:17
aeth
Just the web alone could give you 5 different syntaxes: JavaScript, HTML, CSS, SQL, and the backend language. And if your configuration language isn't JSON, make that 6 syntaxes.
23:44:03
aeth
alexanderbarbosa: no, I mean exactly the opposite... CL's (or Lisp's in general) strongest case is in the web because there are a ridiculous number of syntaxes. In most languages, you'd use something like https://mustache.github.io/ to do {{ foo }} templates on top of the native syntax, e.g. in .html files.
23:44:29
aeth
alexanderbarbosa: In CL, you will have a uniform syntax and a well-designed framework will make the web look like it's not a mix of 6+ syntaxes.
23:44:40
p_l
alexanderbarbosa: to support aeth's point, that's kinda how a bunch of clojure webapps got made :)
23:45:02
p_l
including one that, when it still was available, was all-lisp from web browser to backend
23:47:42
aeth
What's particularly fun is that if you write a trivial macro on top of a well-written function to e.g. generate GLSL, you can then generate GLSL strings at compile time.
23:49:41
p_l
alexanderbarbosa: as for lisp jobs - some lesser known places do still CL, and some switched to Clojure
23:51:10
aeth
Generating a compile time string of another language, once you've written the generation, is probably no harder than (defun foo (s-expression) (with-output-to-string (output) (generate-foo s-expression output))) (defmacro foobar (&body body) (foo body))
23:52:16
aeth
It's a harder if you want the macro to be able to change some output based on the input, like a webpage that says "Hello, ~A~%"
23:53:04
aeth
You can generate JavaScript, HTML, XML, CSS, SQL, JSON, GLSL, etc. Varying quality, though. Mostly hobby, incomplete projects. It's so easy to do that there's a lot of one-off 90% implementations that people have written.
23:53:40
aeth
It's harder if you want to try to get the generated programming language (JS or GLSL) to match CL semantics, though.
23:55:58
alexanderbarbosa
aeth: I dont think someone would hire me if I only generate code from CL :D
23:56:07
aeth
The basic principle is incredibly simple. Parse a list based on the first element, then write to a character stream (many functions that do this), and recursively call if there's another list in there, e.g. (:+ 1 (:* 2 3)) could generate "1 + (" and then "2 * 3" and then go back to the original to add the ")"
0:00:17
alexanderbarbosa
r/lispmemes is more informative than I foresaw... I know that Rust is crap, whatever it is! :D
0:02:58
alexanderbarbosa
aeth: is there any real use of that in web development... if so, I might really take is serious!
0:04:38
aeth
alexanderbarbosa: The use for the web is that you get a uniform syntax for JS or WASM (frontend), (X)HTML, CSS, SQL, CL (backend), GLSL, JSON, etc., and can template using the same macro/function abstractions without having to worry about the differing syntaxes, since that's handled at a different layer of the program.
0:05:09
aeth
The disadvantage is afaik no one did the Rails of this, so it's a bit DIY to glue it all together.
0:07:54
alexanderbarbosa
https://www.reddit.com/r/LispMemes/comments/bidfzc/car_commandments/?utm_source=share&utm_medium=web2x
0:08:29
aeth
alexanderbarbosa: Essentially, what Lisp gives you is a free intermediate format instead of having to directly work with string manipulation. You have (at least) two stages, the s-expression stage and the write-to-stream (usually string generation) stage.
0:17:29
aeth
alexanderbarbosa: I would personally ignore Lisp Memes, Paul Graham, and anyone else who acts like Lisp is the perfect solution for everything. (Although the memes might be joking.)
0:21:40
aeth
I don't really think much about Ada or Rust because what I do isn't really where those languages are used.
0:22:13
aeth
You're much more likely to encounter C++ or Java on the higher performance end or Python or Ruby or JavaScript on the scripting/abstract end.
0:24:06
aeth
Oh, and with gaming in particular, you can add C# to the first list and Lua to the second.
0:28:54
aeth
I can understand (but personally don't really join in on) the hate for Clojure because at least to outsiders it looks like it competes with CL's roles.
0:29:37
alexanderbarbosa
well, after reading some post on r/lispmemes, now I get why no-defun-allowed says that there is no lisp-like languages...