freenode/lisp - IRC Chatlog
Search
17:58:36
dlowe
francogrex: the only thing I can think of is that r% is generating a condition that's being silently swallowed by the repl
17:59:50
sjl_
2019-01-11 12:44:23 <scymtym> if the implementation's REPL establishes an ABORT restart, the behavior could be caused by code like (multiple-value-list (handler-bind ((error #'abort)) (/ 2 0)))
18:02:57
francogrex
like the easy one that does not require changing the code? I guess it would be to
18:03:08
sjl_
Depends on what you're actually trying to do. Are you trying to detect when this happens?
18:08:14
dlowe
you can also (declaim (sb-ext:muffle-conditions style-warning)) at the top of the file
18:08:16
sjl_
Ideally you'd fix the code to not emit warnings. To hide the warnings, use the solution found in the first google result for "sbcl disable warnings"
18:09:09
dlowe
declarations about variables occur at the beginning of the body of the variable's scope
18:13:44
cryptopsy
should i use *standard-input* or *terminal-io* nil EOF for runnning my lisp program with a parameter which is the filename it is supposed to read
18:15:31
pjb
*standard-input* is for batch input. *query-io* is for interactive I/O. *terminal-io* is to communicate with the operator (and it cannot be rebound).
18:16:18
pjb
If you open a file you can rebind *standard-input*: (with-open-file (*standard-input* pathname) (read))
18:17:16
cryptopsy
i can't get *standard-input* to work ,, this was my usage #sbcl --noinform --disable-debugger --load test.lisp tests/alphabet.x
18:20:13
pjb
sbcl --noinform --no-userinit --disable-debugger --eval '(progn (print sb-ext:*posix-argv*) (terpri) (finish-output) (sb-ext:quit))' -- tests/alphabet.x
18:20:46
pjb
sbcl --noinform --no-userinit --disable-debugger --eval '(progn (print sb-ext:*posix-argv*) (finish-output) (sb-ext:quit))' tests/alphabet.x
18:25:38
pjb
cryptopsy: lisp is easy to understand: you look at the first word in the parentheses, and look it up.
18:26:01
pjb
and then you repeat with the sub expressions that are evaluated, according to what you read in the specification.
18:26:51
pjb
cryptopsy: you can copy and paste the irc buffer, and take your time to read and study it. Somebody will still be there when you come back, in 1 hour, 1 day, 1 month or 1 year.
18:29:31
cryptopsy
the practice is, when you have 50 tabs open, u read the first few lines, and if it doesnt answer, you go to the next
18:29:44
pjb
cryptopsy: again, I've shown you how to do it. Why you keep writing wrong forms? If you don't want to learn, don't come here.
18:32:12
pjb
dlowe: when people say they don't want to learn, and show that they don't learn anything, nope.
18:33:23
pjb
I give my time for free, if it's to throw it to the trash, it's VERY RUDE. So fuck off!
18:33:44
cryptopsy
""The only required argument to OPEN is the name of the file to read."" interesting, just like all the other 1000 lines irrelevant to what i have in my program
18:33:45
grewal
cryptopsy: It sounds like you need a small break to process everything. Learning a language takes time. Copy-and-pasting and brute-forcing can only get you so far
18:35:14
cryptopsy
so i'm looking at this huge ammount of data (pictured her https://i.imgur.com/VCJsrVN.png) , and then i'm looking at my line, pictured here https://i.imgur.com/VCJsrVN.png
18:36:16
pjb
cryptopsy: this is why you should read a tutorial from start to end. Tutorials are short and pedagogical. You can read and LEARN 50 pages in a week.
18:36:17
buffergn0me
cryptopsy: It looks like you might be confusing streams/file descriptors with file names
18:37:32
cryptopsy
(now im looking at my imgur script which i replaced earlier, wondering why it didnt produce a link ..)
18:38:40
dlowe
CL is a fairly hard language to just dive into without going step-by-step through a learning book
18:39:06
dlowe
My learning book was Common Lisp: the Language, which I don't recommend but it was there at the time.
18:40:08
cryptopsy
*standard-input* isnt even on http://www.gigamonkeys.com/book/files-and-file-io.html
18:42:05
buffergn0me
cryptopsy: Well, are you trying to read from stdin or open a file? Totally different things
18:42:23
dtw
cryptopsy: You seem to think that you need *standard-input* stream. Do you know what it is?
18:47:05
aeth
dlowe: Manual freeing gets you a lot of unwind-protect... you can already see this in CFFI code where you control the allocations
18:48:48
buffergn0me
cryptopsy: I think it would help if you read a Unix introductory programming tutorial that covers file and IO system calls. The CL tutorials cover CL specific stuff and assume you know about file descriptors and the filesystem
18:50:43
buffergn0me
cryptopsy: Something like Stones and Matthew's Beginning Linux Programming explains files, file descriptors, pipes, and IO redirection, and you can use it as a reference
18:58:33
cryptopsy
when i decide how to handle command line parameters in a case i will deal with that case
18:58:53
cryptopsy
i was hoping to have solved this in 30 seconds while taking my mind off a recursive function
19:05:33
pjb
Well, only once you realize those 40 lines can be written in 10 if you use CL instead of re-implemeting functions like count or find…
19:12:10
polezaivsani
for asdf's defsystem, the manual states that :depends-on can have a list of component names. does it mean a system can depend not just on other systems, but also file components?
19:14:32
polezaivsani
dlowe: how does it help defining inter file deps when it's being set within a system definition? n.b. i'm totally new around here
19:16:55
pjb
(defsystem :foo :depends-on ("other-system-1" "other-system-2") :component ((:file "foo1") (:file "foo2" :depends-on ("foo1")))
19:18:35
polezaivsani
that's clear for system's components, but can e.g. "other-system-1" or "other-system-2" be infact a non system component?
19:20:46
polezaivsani
the hole reason, i'm asking it is i stumbled upon a system definition like (defsystem foo :depends-on ("split-sequence")), and as far i could figure, split-sequence isn't a system anylonger. Could it be that it's just an old definition from time where split-sequence was a system by itself?
19:23:18
polezaivsani
oh, so it's not being part of cl-utilities, it's just being rexported from it, right?!
19:24:36
phoe
(and got a decent overhaul in the process, https://github.com/sharplispers/split-sequence/pull/13)
19:25:06
aeth
Tangentially related, but splitting sequences is probably the wrong way to deal with most things in CL. For arrays you can just work with indices, for lists you should think about if you e.g. really want to turn '(a b c d) into '(a b) and '(c d) or if you just want '(c d) which is far more efficient (or similar list tricks).
19:25:41
polezaivsani
oh, i see. i happen to get the wrong idea from glossing over a quick cliki search
19:25:46
phoe
polezaivsani: also, from what I see, most of cl-utilities made its way into alexandria
19:27:00
_death
though it was explicitly ruled out at the time, I think it'd be nice by now to put split-sequence into alexandria ;)
19:28:00
aeth
phoe: You can often/usually just subseq as the final (in the program) step and save a bunch of intermediate splits
19:28:11
_death
phoe: the idea was explicitly rejected when alexandria was created.. I know it will be rejection still
19:29:09
polezaivsani
nice, from a couple hour long acquaintance with cl-utilities i didn't manage to like the name :) thanks for the tips!
19:30:53
_death
personally I use split-sequence a lot, and have great distaste for ppcre or other regex packages (unless they're part of the UI.. then they're ok)
19:33:50
dlowe
if you're doing string processing, you have already lost the clean data model. Might as well regex it up
19:34:37
pjb
aeth: this is why there's com.informatimago.common-lisp.cesarum.array:positions-of-subsequence
19:35:07
_death
dlowe: not my experience.. I have used regexps for some quick hacks, but usually there's no need
19:36:37
aeth
pjb: Right (at least about the principle, never used the library), you work with position indices until the final step and then you only do the final subseq(s). This saves a lot of intermediate subseqs since you only need to subseq the strings
19:37:22
aeth
If you're parsing some data format it'll probably be like 95% read-integer or direct string matches (like "true" to t) and 5% actually saving some of the string data
19:37:33
pjb
Compar: (values (split-sequence #\SPACE "Hello World, How do you do?") (positions-of-subsequence " " "Hello World, How do you do?")) #| --> ("Hello" "World," "How" "do" "you" "do?") ; ((5 . 6) (12 . 13) (16 . 17) (19 . 20) (23 . 24)) |#
19:38:11
pjb
aeth: however, creating short substring is usually very efficient, even compared to consing and working on subseqs.
19:38:29
_death
usually such string processing happens at the edge of the system, you receive some input, parse it into an internal representation, and then the real processing happens
19:38:39
aeth
_death: Well, it's more about how CL was designed to handle vectors (including strings)... which is with all relevant built-in functions (and all well-written third-party) functions including start/end indices
19:39:20
aeth
_death: of course you can use a surpirsingly heavy library to use your own model.... turing complete and all
19:40:00
cryptopsy
less interested in print becaues i have read it is outdated but it was a desperate attempt
19:41:13
pjb
write is a low level function that use a bunch of global variable parameters as defaults. princ, prin1 and print just call write, with specific values for some of those parameters.
19:42:25
_death
aeth: I use start/end as well.. but I wouldn't normally store indices to strings without evidence that it matters
19:42:29
pjb
Yes, this is the first thing all lisp tutorial would have taught you, if you wanted to learn anything.
19:42:44
cryptopsy
must have gotten confused about the syntax from some shitty stackoverflow posts along the way
19:43:18
_death
aeth: I do think it's a good idea to provide start/end functionality when writing string/sequence utilities
19:43:21
pjb
cryptopsy: this is why I gave you this link http://cliki.net/Online+Tutorial and not a shitty stackoverflow link!
19:43:54
_death
aeth: in fact I remember an old presentation by tcr when he proposed some nice operators to help do just that
19:44:45
pjb
cryptopsy: the source of lisp code is a lisp object, a symbolic expression (s-expr), which is an atom or a list of s-exprs.
19:45:34
phoe
cryptopsy: yep, some people don't like it, since it isn't very "lispy". As in, it lacks parens.
19:46:06
_death
cryptopsy: maybe try to avoid the long form of loop for now.. instead you can use DO.. I think newbies should go through no-loop phase at some point
19:46:35
cryptopsy
what should i use to inspect my terms for debugging? i think that would be useful
19:46:56
phoe
#'MACRO-FUNCTION and #'SPECIAL-OPERATOR-P will return NIL if passed a symbol that isn't bound to a macro or a special operator.
19:47:02
aeth
_death: The only time I wouldn't use start/end on strings, personally, is if something was mutating them somewhere along the line. Even there, it'd probably try to find some way to make it work. Of course, this is assuming elaborate processing. At the end, SUBSEQ makes sense if it is supposed to be stored as a string, of course.
19:47:48
phoe
cryptopsy: you really need to do some basic reading on Lisp. It's hard to help you if you don't know basic concepts such as quoting.
19:47:53
aeth
_death: If it's just a CSV into an object holding strings or something similarly simple, sure, splitting makes sense
19:48:05
cryptopsy
it was a last minute decision to use lisp, i came here from watching a scheme presentation
19:48:23
phoe
cryptopsy: well, you don't walk into a new language and start using it straight away without learning it first.
19:49:22
aeth
cryptopsy: Usually people use IDEs, which expose the API of the function/macro. e.g. in a properly configured Emacs+SLIME, it will show up in the mini-buffer at the bottom. It's usually extremely obvious by the API if it's going to be a macro because it will have stuff like (foobar (x y) (&rest foo) &body body) that are impossible in function APIs
19:49:58
aeth
cryptopsy: of course, relying on the API isn't perfect because people could be e.g. using macros instead of inline functions (justifiably or not)
19:50:59
phoe
if you use Linux, ctrl+d to drop from one debugger level or to quit if you're at the toplevel
19:51:25
aeth
cryptopsy: macros are functions but they run before runtime. They take in source and output source. e.g. foobar 42 43) => (let ((x 42) (y 43)) (+ x y) (values x y (+ x y)) ; of course all trivial macros are probably better done as functions so this example is bad
19:52:00
cryptopsy
i am just working on my crapper lexer while trying to stimulate interesting discussion
19:52:35
phoe
cryptopsy: you're not going to write good code if you don't know how to use your language. I suggest you read Practical Common Lisp first.
19:55:35
aeth
The Little Schemer (current edition) actually covers one of the few parts of Scheme where it doesn't have much in common with Common Lisp.
19:57:11
cryptopsy
the troll who uploaded this pdf wasnt kidding, fully zoomed in mupdf it is that size
19:59:25
cryptopsy
this clisp pracice will come in handy for migrating to stumpwm from ratpoison (abandonware)
20:04:40
jasom
cryptopsy: yes and no. They are similar in that they both implement a rather large specification. They are typically very different in underlying nuts and bolts
20:05:44
White_Flame
Clasp is intended for strong C++ integration, ECL is based on strong C integration, SBCL's compiler usually generates the fastest code, CCL had the broadest platform support for a natively compiled version, CLISP was interpreted and thus highly compatible, etc
20:05:55
jasom
clisp has a bytecode interpreter written in C that is targeted by the lisp compiler. sbcl compiles directly to machine code. ecl generates C that is compiled via a C compiler.
20:07:54
White_Flame
of course, llvm is kind of based around simpler language models, so there's still a lot of work to build a language on top of it that has higher level native language abstractions
20:08:59
jasom
llvm is reinventing the wheel in the sense that most compilers already had an internal IR; its not reinventing the wheel in that there wasn't a well maintained portable IR.
20:09:26
jasom
gcc kind of intentionally made its IR a moving target to prevent proprietery software from using it.
20:10:45
cryptopsy
what other syntax irregularitys deviating from (function ...) notation should i watch ot for besides loop ?
20:10:51
jasom
it relies on SBCL_HOME being set properly, so you need to source /etc/profile after installing it, and if you run it with an empty environment it won't work
20:12:20
White_Flame
jasom: beyond that, it usually isn't pointing to its own source code properly, and had been quite far behind in versions
20:14:37
jasom
ACTION wonders how many standard macros/operators have implicit tagbodies; prog and friends, do and friends, probably more...
20:14:44
_death
backquote could also be confusing to a newbie.. when it's no longer confusing, congratulate yourself and try nesting them
20:20:51
jasom
grewal: I mean the body of the macro creates an implicit tagbody like PROG or any macro starting with "DO"
20:21:07
_death
always fun to poke at C's printf, that (in practice) has to keep interpreting the control string over and over, while Lisp has FORMATTER
20:22:08
White_Flame
C compilers don't break down literal format strings at compile-time? that would surprise me
20:23:29
_death
White_Flame: it's been a while since I reverse engineered stuff, but in my experience, no they didn't
20:23:37
p_l
White_Flame: they don't, at least not unless they have some guarantee that the call to formatting function is to known-to-them implementation of format
20:27:05
polezaivsani
oh, yeah, i was frightened by an idea of interpreting it more than once in a single call )
20:27:11
jasom
in fact it's a classic bait-and-switch to do something like printf("Look: %s",NULL); printf("%s\n")
20:27:34
jasom
in fact it's a classic bait-and-switch to do something like printf("Look: %s\n",NULL); printf("%s\n",NULL) and see the first print (null) and the second segfault
20:27:46
White_Flame
anything with any level of abstrction will end up running an interpreter instead of being resolved at compile time
20:28:07
White_Flame
even runtime JIT languages should outpace C if there's such forms of abstraction involved
20:28:55
jasom
meh, many performance-sensitive applications are a microbenchmark dressed up as a complicated program (i.e. 90% of the time is spent in a single loop) so C does well on those as well.
20:29:13
p_l
_death: because at compile time they don't know what printf is other than a vararg function
20:29:41
jasom
p_l: not at all true; C compilers very often will optimize standard library functions
20:30:23
White_Flame
jasom: if 90% of the time is spent in dispatch & decisions, then there's not much you can easily do in C
20:30:50
jasom
p_l: It's not a non-standard extension as long as the program behaves externally like the abstract machine...
20:31:14
jasom
just like clisp and sbcl will behave very differently with regards to performance while both of them being standard.
20:31:45
p_l
jasom: except the abstract machine specifies that memcpy() is a function call, and in fact you can get tripped by it
20:33:00
jasom
p_l: only thing a function call does is insert a sequence point. There is no other externally observable behavior for a function call.
20:33:39
_death
if in C the compiler writer is the wizard, so does in Lisp, but in Lisp you get to be the compiler writer up to a certain point ;)
20:34:52
jasom
If I work on a C compiler *and* I program in lisp, does that make me a wizard squared?
20:37:46
_death
fancy nowadays.. I've worked from home this last year (with occasional trips to fields.. actual fields.. for experiments)
20:38:09
jasom
It turns out drywall isn't that much more expensive than cubicles; once the CEO discovered that all the cubes disappeared
20:39:09
jasom
the larger offices go to new hires and those weird people who like sharing an office.
20:41:41
jasom
It's like 2x more than midrange 5' cubes as long as you are doing a lot of it. And the 5' cubes suck because of the "gopher effect"
20:42:33
jasom
I'm fortunate enught to be able to turn down work, and I ask about open office before doing an onsite
20:43:04
jasom
I have this weird tick where if someone walks behind me it completely disrupts my train of thoughts.
20:43:26
Josh_2
Put something offensive on the back of ur shirt and no one will want to walk behind you
20:44:12
_death
jasom: yes.. during experiments they set up a gazebo, a table, a battery, a screen and a keyboard for me to connect my laptop to.. and I had to operate stuff while people watched behind my back.. ugh
20:44:27
grewal
My only issue is that I know where everybody's schedule and everybody knows mine. I really don't like knowing about people's regularity
20:48:54
gilberth
cryptopsy: There are no "expressions" in Lisp. The is not this distinction between statements and expressions like in many other languages. Everything is a FORM and evaluates to some value.
20:49:50
gilberth
Josh_2: And how is that more an expression as the other? And is it better? For a start you spell READ-LINE twice.
20:50:49
jasom
ACTION has always used the terms "form" and "expression" interchangeably. statements are different though.
20:50:59
gilberth
Right. But do you believe that is good advice for cryptopsy? /me must be the only person who still uses DO.
20:53:16
gilberth
Josh_2: DO is fine at times. I do not use it that much anymore. And LOOP, once it arrived was heaven. All I was saying was that I believe it not good advice in this case.
20:54:59
gilberth
Yes, and a line later he corrected himself and was refering to the LOOP form. This is how I understood that. Maybe I misinterpretated that.
20:55:15
_death
gilberth: I believe it's a good idea to experiment with different styles.. LOOP has its affordances but also inhibits certain ideas.. so I think as a person progresses in learning CL, at some point there should be a phase w/o LOOP, a phase with heavy recursion, a phase with over-use of LOOP, etc.
20:56:06
sjl_
I often end up writing my own iteration construct (with do/loop/iterate/whatever) and then using that
20:56:24
jasom
Josh_2: https://codegolf.stackexchange.com/questions/57984/loves-me-loves-me-not/58046#58046 example gode colf in lisp
20:59:11
_death
sjl: but the code you pasted has an issue.. a pitfall that often comes from using LOOP in a macroexpansion
20:59:42
sjl_
_death: using alexandria:parse-body and adding a docstring to mention nil block left as an exercise for the reader :)
21:17:18
sjl_
You mean as the thing you're binding to a local var? like (let ((foo (case ...))) ...)? Sure. It's hard to say whether it's the "best way" without an actual example.
21:19:30
sjl_
If you pastebin the code you already have somewhere, it would make it easier for us to give you advice.
21:20:05
cryptopsy
if prev and current are nil, then its the start of the file, so i need to give lines to those vars
21:22:01
pjb
White_Flame: Yes, you can optimize run-time format strings: (let ((fmt (formatter (read-line)))) (loop repeat 1000 do (format t fmt args)))
21:22:52
pjb
Also, remember that the format control can be a function: format control n. a format string, or a function that obeys the argument conventions for a function returned by the formatter macro. See Section 22.2.1.3 (Compiling Format Strings).
21:24:40
cryptopsy
i feel like im forced to use if , if i want to compare if both prev and cur line are NIL
21:26:00
sjl_
you might start with something like https://plaster.tymoon.eu/view/1281#1281 but again, I don't know what you're actually trying to do
21:27:15
_death
(loop (shiftf previous current (read-line ...)) (cond ((null current) (return)) ((null previous) first) (t rest)))
21:32:19
cryptopsy
this is my attempt for checking if line-prev and line-cur are both NIL (cond ((= (line-prev line-cur)) NIL)
21:39:54
cryptopsy
so as i understand it i need to construct a predicate that compares multiple things
21:40:07
jackdaniel
that depends on the perceiver. I feel like a magician even after I came to a solid conclusion that I have an impression that I understood what I did ;)
21:41:27
cryptopsy
gilberth: they're objects which contain lines read from file. if no line is read i expected them to be nil
21:44:53
sjl_
and both phoe and I have given them their answer of (and (null prev) (null cur)) so I'm not sure what else to say here
21:45:03
cryptopsy
>>>>>>> (and form1 form2 ... ) evaluates each form, one at a time, from left to right.
21:46:08
gilberth
phoe: It is pointless IMHO. When you were passed a dotted list the subsequent CAR would catch that anyway. Fine with me.
21:46:32
phoe
_death: but, well, "(...) a situation that has undefined consequences will eventually result when the non-nil atom (which is not in fact a list) finally becomes the argument to endp. (...)"
21:46:44
gilberth
phoe: Supposing you CDR down a list and test with NULL for its end and do something with the CAR.
21:50:17
_death
phoe: endp by itself has no undefined consequences.. the poor man may misinterpret its answer though
21:51:20
_death
phoe: I guess another use for it is to show intention.. "look, I'm supposed to be working on proper lists"
21:55:21
sjl_
cryptopsy: you should go through https://www.cs.cmu.edu/~dst/LispBook/ or http://www.gigamonkeys.com/book/
21:57:28
sjl_
Sure, but thinking !null might work is a sign that you should probably start by learning the basics in a structured way, rather than just throwing everything at the wall until something sticks.
21:58:16
sjl_
Common Lisp is a big language that's very different than many other languages. It's worth spending some time learning the basics.
22:02:57
cryptopsy
i think i need to change ((and prev cur) to ((and (not(null prev)) (not(null cur)))
22:06:40
nirved
you should read an introduction book, trying to learn CL this way would be very counter-productive
22:07:41
Josh_2
bending my mind to the dirty tricks of languages like Java after having learned CL first :O
22:10:56
cryptopsy
i presume ((and (not (null prev)) (null cur)) is equivalent to ((and prev (null cur)) ?
22:11:37
Josh_2
also a lot of thoose tutorialspoint.com CL guides drop trailing )) onto newlines, ples don't do this :(
22:13:13
cryptopsy
this is useful for me because sometimes i find myself solving a problem backwards , so i have to do a lot of moving blocks around to get it to work
22:13:47
gilberth
cryptopsy: However, why do you test 'prev' and 'cur' anyway? Why don't you always make 'prev' being 'cur', 'cur' being 'next' and 'next' being 'line'?
22:14:10
Josh_2
cryptopsy: http://echomon.co.uk/wp-content/uploads/2013/02/Sad-Puppy-Face-Picture.jpg
22:14:49
cryptopsy
Josh_2: the goal of this program is to produce valid lisp from block-notation code so it should produce nice code once its done :D
22:15:52
cryptopsy
parse-ident tells me the indentation level of a line, now i will compare lines to place ()'s around
22:17:46
cryptopsy
for example, if prev is indented 3 and cur is indented 4 we know cur is a child of prev
22:25:21
cryptopsy
having read the gigamonkeys page for loop macro, is my placement of brackets acceptable? https://i.imgur.com/KFu34ya.png
22:25:51
cryptopsy
i am confused because previous to adding let, i did not have "do (" at the end there and the program ran
22:33:13
cryptopsy
in (loop there is do (something)) and the syntax for let is (let ... ) , so does that become (loop ... do ( (let ...)) ?
22:39:18
_death
this does not show loop's grammar.. try http://www.lispworks.com/documentation/HyperSpec/Body/m_loop.htm
22:40:18
Josh_2
There are a few other docs that take the hyperspec a lil further but they are not complete yet
22:42:51
cryptopsy
i have a let and a while that need to go in this do, i imagine the syntax is (let ...) and (while ...) ?
22:43:16
_death
cryptopsy: there you can see the "unconditional" rule: {do | doing} compound-form+ .. i.e. do should be followed by one or more compound forms.. for compound-form there is a link to the glossary, which says that it's a non-empty list which is a form.. (let ...) is an example of a compound-form
22:45:55
cryptopsy
so i have a cond and a while that need to go in this loop, i added do () around them both since there are two things that need to be done
22:46:32
cryptopsy
cond i assumed was a function, but i think i read somewhere its a macro? not sure what im doing really
22:47:14
cryptopsy
the only thing holding this bastardization together is the indentation in this pseudocode
22:49:11
cryptopsy
in my attempt i didn't put this becasue the one just above after do is there, i thought it was sufficient
22:50:03
cryptopsy
should in retrospec i think it should be there because the hyperdoc is showing that as the form
22:51:20
_death
cryptopsy: there are several issues with this code.. for starters, aside from bad indentation, while line should be done right after the for clause, and the let (but not its body) should be pulled out of the loop
22:52:21
cryptopsy
if the let is pulled out of the loop for line, then it can't assign values to its locals prev and cur
22:59:06
cryptopsy
00:52:00 _death | (let (prev cur) (loop ... do (cond ((and (null prev) (null cur)) ...) ...) ...))
23:05:48
_death
since you've been shown loop's grammar, it's time to try to formulate a sentence according to it.. good luck.. sleepytime
23:15:35
cryptopsy
how does lisp iterate through these two lists in parallel internally? Does it iterate the first for, and then append the 2nd for? https://i.imgur.com/QIUnelm.png
23:16:41
White_Flame
a single LOOP describes a single iteration. If you nest LOOPs, then you'll have nested iteration
23:16:45
no-defun-allowed
so, it'll check if either list is null, then pop the X list, pop the Y list and use those to bind X and Y, then repeat
23:18:42
White_Flame
FOR ends up being a red herring when coming from other languages, where multiple FORs imply multiple iterations
23:18:49
no-defun-allowed
imagine it like (let ((x-list ...) (y-list ...)) (block nil (tagbody step (when (or (null x-list) (null y-list)) (return) (do-body (pop x) (pop y)) (go step)))
23:18:50
cryptopsy
so in this case https://i.imgur.com/JN9szr9.png , for for while are all 3 in parallel ?
23:19:28
no-defun-allowed
in that case with the =, X is evaluated first, then Y uses that binding, then WHILE uses both values
23:20:27
no-defun-allowed
but iteration constructs are done in parallel, i think computations like = and while are set up like let*
23:22:26
no-defun-allowed
FOR ... IN only stops when the whole list has been stepped through, which is how you'd expect list iteration to work
23:22:56
cryptopsy
i've updated my form as follows for better understanding https://i.imgur.com/v9V5k1S.png
23:25:31
cryptopsy
i have a do () block here, i'm not going to delete lines just to produce a concise paste
23:26:25
Bike
i don't want to ban you, i just don't want this slow walkthrough of loop semantics to dominate the channel
23:26:41
pjb
cryptopsy: can't you understand that #clnoobs would be more tolerant of your newbie questions?
23:33:59
White_Flame
CL has a lot of very specific terminology and complex cases which normally foil people trying to learn the basics, which is why it's split off
23:38:01
pjb
(loop for item in '(a b c) for i from 1 to 3 collect (list item i)) #| --> ((a 1) (b 2) (c 3)) |#
23:50:53
tsizz
hi im just learning lisp in class... i was curious what lisp is used mostly to make nowadays
23:59:18
Josh_2
Common lisp is multi paradigm, it is not purely functional but has support for functional if you want to write code that way
23:59:56
pjb
tsizz: don't wonder. The pedagogical goals can be very different from your goals and may be strange.
0:01:07
pjb
tsizz: the goal of a teacher is to maximize the teaching of what he has to teach, while minimizing his work (eg. answering to questions accessory to the teaching).
0:01:38
pjb
tsizz: so he will choose a simplier language that may demonstrate more clearly the things he has to teach you, but which is not necessarily the language you would use to develop a real program.
0:02:23
pjb
tsizz: they're languages that have been simplified so that whole classes of questions don't occur, so the teachers can concentrate on what he wants to teach.
0:03:50
gilberth
tsizz: Pure functional programming concepts are an important topic. But neither Scheme nor Common Lisp force you to stick to it. It is just a teaching tool for your class in this case. Don't be fooled.
0:05:23
LdBeth
tsizz: if you aren’t gonna to study Godël’s type system then that’s all u need to know about functional programming
0:06:12
aeth
tsizz: Purely functional programming is literally impossible in any useful program because of I/O. Newer languages like Haskell solve this problem with monads. If you want to know what a monad is... well, this isn't the place to ask, I certainly don't know.
0:07:11
pjb
tsizz: Have a look at "Paradigms of Artificial Intelligence Programming: Case Studies in Common Lisp".
0:07:45
gilberth
I believe the most important think is, that functions are first class objects in Lisp. But then there are also in JavaScript, which is a Lisp with a very funny syntax.
0:08:37
LdBeth
Monad is actually about an interface modify complex structures, in Haskell side effects are warped in those kinds of structures and that’s all
0:12:18
gilberth
LdBeth: Well, this is the classical story. Students are exposed to Scheme called a Lisp and are teached pure functional programming, which in general is hard to grasp. And then they think: "What a shitty language!"
0:12:32
moldybits
tsizz: give PAIP a shot. it's one of my favorite cs books of all time. peter norvig (the author) has some very enjoyable videos on youtube, as well.
0:13:52
tsizz
gilberth: haha thats why my teacher gave us that article. the author explains his thoughts on that
0:15:43
LdBeth
You can get Spacemacs and they’re provide CL/Scheme/Haskell config out of the box with Vim like key bindings
0:18:21
gilberth
Long, long time ago I got my first Unix, which was Xenix [sic!]. First thing, I did was to unplug the speaker because of all the BELs. Next thing was to port uemacs to it.
0:18:39
Elronnd
I always thought it was kind of sad that emacs.dev and vim.dev both redirect to vim's website
0:22:11
moldybits
then again, given the choices made thus far they'd probably make it even more primitive than elisp, so i guess not.
0:23:03
LdBeth
Vi sucks because they want vi key bindings on their car, rather than the choice of config lang
0:29:45
seok
So if different processes try to access the same variable on an unlucky occasion, one will get an error?
0:29:49
LdBeth
But to catch the fashion there’s Actor models and process calculus abstract the low level
0:33:47
gilberth
Both will be executed, but on unlucky circumstances one thread will have a "stale" value for 'a'.
0:35:29
gilberth
Well, when I understand the problem correctly. You want that if one thread tries to increment by 1 and the other by 2 you want a guarantee (sp?) that 'a' is incremented by 3, right?
0:38:53
gilberth
This has nothing to with Lisp. This happens in any language. The problem is: To increment a variable, you read its value, do the addition and write back the result. While you do the addition the value could be changed by another thread.
0:40:15
tsizz
i don't really understand the difference is between static type checking from compiler vs. runtime
0:40:16
gilberth
So you need to guard access to the 'a' variable. For that you use a lock. You have a lock for that variable. Before entering the increment operation (reading, incrementing, write-back), you aquire the lock and get exclusive access.
0:44:57
aeth
cryptopsy: Swank is a way to communicate with a Common Lisp server over TCP, for interactive debugging development.
0:45:44
aeth
cryptopsy: So it's sort of like LSP if you're aware of it https://en.wikipedia.org/wiki/Language_Server_Protocol
0:46:49
cryptopsy
don't automatically assume i know what a SHOUT is, afterall i barely understand function
0:47:32
aeth
cryptopsy: So for historical reasons Common Lisp is "case insensitive" by default in that it upper cases everything it reads, so foo becomes FOO. This means that Lispers are usually used to entering 'foo and getting FOO back. So a lot of Lispers randomly upcase things, including some who say LISP, randomly upcasing Lisp itself.
0:49:46
aeth
It's actually sometimes useful to refer to functions (or macros) in upper case in prose, such as CAR and CDR and CONS, even though we always by convention write source code in lower case these days
0:51:10
bjorkintosh
aeth, lisp is old and hard of hearing and has a noticeable speech impediment, so it THOUTH.
0:52:09
aeth
cryptopsy: Every ugly part of software (and programming languages are just software) basically has to have a mini-history lesson because if it's ugly and everyone immediately notices it "historical compatibility" is probably the reason why it is the way it is.
0:53:03
aeth
The only thing worse than a mildly ugly feature is writing something that worked 10 years ago and no longer works today. Except a lot of people no longer hold that attitude, which is why in some ecosystems you have to rewrite your software every few years. What a mess.
0:54:18
aeth
cryptopsy: Well, Scheme is more consistent because it broke backwards compatibility with early Schemes
0:54:53
aeth
(and Racket itself broke backwards compatibility with Schemes a while back by making cons cells immutable)
0:55:55
aeth
cryptopsy: With Common Lisp, you can run LISP 1.5 (in this case LISP because they had no lower case on computers back then!) programs with minimal changes. It values backwards compatibility, so it has some rough edges that you either just have to accept or learn why it is the way it is
0:57:10
aeth
This also means it has some macros and functions that (almost) no one uses like PROG and RPLACA
0:57:19
cryptopsy
i wonder if the swank from the simpsons is the same swank as in lisp, the show wad some writers which were math grad students
1:01:49
aeth
cryptopsy: To understand SLIME (Emacs) or Slimv (vim) you have to understand the Common Lisp workflow, which is fairly unique. Really, only one other language that I know of (Smalltalk) really thinks like this. It's about running things in an interactive image. It is basically like the REPL you might have seen in Python or JavaScript, except considerably more advanced.
1:02:09
aeth
Lisp actually invented the REPL (read-eval-print-loop) and you can sort of get a primitive REPL just by doing (loop (print (eval (read))))
1:04:39
aeth
cryptopsy: Most programming languages think in the Unix way (usually because most programming languages are made for Unix and then later get ported to the other OSes) of having a text program that is compiled or interpreted, but essentially working at the file level.
1:05:16
aeth
Common Lisp doesn't really necessarily care about files. You use something like ASDF (and Quicklisp on top of ASDF) to make it care.
1:05:33
White_Flame
FORTH has a somewhat similar workflow to Lisp, except that there are more ordering issues on definitions
1:08:09
aeth
cryptopsy: There are implementation specific ways to get an implementation like SBCL to load a file and treat it like it's a Unix scripting language (except implementations like SBCL are natively compiled! so the compiler will have to run first!), but what people commonly do when developing is just work directly in the interactive image, usually through something like SLIME or Slimv to make the REPL friendlier to work with.
1:08:55
aeth
And if you're doing an advanced program the way to do an executable is to actually get an image and then save the image! In SBCL it's save-lisp-and-die.
1:09:28
aeth
The distinction is the latter approach will bundle the language runtime with the executable, and the former approach requires you to have the implementation installed locally.
1:10:56
aeth
When developing you just keep the interactive image running in the background, perhaps restarting it every now and then if things break or to make sure your program will work with a fresh image.
1:11:34
aeth
This "in the background" Lisp has to run a swank server so your IDE (or whatever else) can talk to it.
1:11:56
aeth
(It doesn't have to be swank, but if it's not swank, you'll probably have to write the server protocol yourself.)
1:15:05
aeth
cryptopsy: All of that gigantic wall of text explains the design, but if you want you can just see how someone interactively codes Lisp live for a web stream (in this case, using Emacs). https://youtu.be/aiJxkaxMBVE?t=555
1:17:21
aeth
Don't be intimidated by that video, though. He's more efficient at that sort of thing than most of us are because he does it for livestreams.
1:35:49
pjb
tsizz: the thing to understand in static type vs. dynamic type, is that in the case of static typing, the type is associated with the variable: any bit pattern stored in a variable of type T is interpreted according to the type T.
1:36:35
pjb
tsizz: on the other hand, with dynamic typing, the type is associated with the value. The value can be stored in any variable, it brings with it its type. So you can never make a typing error with dynamic typing, because you always know the type of the value you have.
1:38:54
pjb
tsizz: so when the variable is typed, you can blindly use the bit patterns stored as if they were of the type of the variable: this is fast, but if the bit pattern is invalid, this is catastrophic: you get crashes or worse like in C programs. The solution is to let the compiler prove that the bit pattern stored in typed variable are always valid, but this implies strong constraints on what you can do. cf. Haskell.
1:39:10
aeth
pjb, tsizz: And you can have both at the same time, such as how SBCL typically interprets type declarations (which can be given meaning by implementations)
1:39:42
aeth
It avoids the mess of something like Haskell or Java by... not really having the ability to get too elaborate in the types held by data structures, though. For the most part, you're holding T.