freenode/lisp - IRC Chatlog
Search
13:17:05
cryptopsy
i am trying to call the function that returns the line in while line do but i am not sucessfull
13:20:34
cryptopsy
i think i might be in the wrong dir and the file it is supposed to open is not there
13:21:55
cryptopsy
i used to have a zone of dead pixels where i am keeping the sbcl window, but even after changing the screen my mind is still recognizing that zone as dead pixels and doesn't immediatly focus on the text in that corner
13:23:42
cryptopsy
i am a gentoo user, i have to set app-editors/vim python_single_target_python2_7 , this seems weird to me because it is set in make.conf
13:25:28
grewal
From the turorial, "You will also need a Python enabled Vim, and the same Python version installed that is Vim compiled against."
13:26:46
cryptopsy
perhaps because it is built with PYTHON_SINGLE_TARGETS python3_6 but slimv wants python2_7 on itself
13:28:21
grewal
vlime doesn't require python. But if you want paredit, you'll have to install that separately.
13:31:55
cryptopsy
it has been my dream this last decade to do that and i only have 3 days it until i start a career that won't permit me to have this hobby anymore
13:36:19
cryptopsy
what is the data-type of lines from (loop for line= (read-line stream nil) , i think it is a string?
13:44:35
gilberth
cryptopsy: What should the function do anyway? Counting the leading #\Space characters?
14:00:55
cryptopsy
i am aware there are many ways to do it, i am doing this as a learning exercise with primitives i understand
14:20:51
cryptopsy
i am attempting to write this function that takes a string but returns the value of a local variable
14:22:06
cryptopsy
would this be better to have beeen written as a recursive function considering the indents are almost always less than 20 ?
14:39:00
jurov
Can anyone please enlighten me why in my recursive function these two forms behave differently: (concatenate 'list '( [ ) (recurse x) '( ] ) ) and `( [ ,@(recurse x) ] )
14:41:40
Bike
cryptopsy: they may be garbage collected at any point at which they are no longer reachable.
14:43:43
cryptopsy
or are all the exercises virtually the same but in the lisp lang instead of scheme
14:44:21
cryptopsy
Bike: if the function ends, and is never used again, does it still have allocated that local var somewhere
14:49:06
sjl_
I think it's pretty uncommon for a garbage collected language to define when garbage collection of local variables occurs.
14:49:14
cryptopsy
so i am reading here: """ While Garbage Collection (GC) was one of the major innovations of Lisp, there have been many attempts to get rid of it in one way or another. """
14:50:36
sjl_
Tell Bike you have a local variable pointing at a 10gb array and you want to know when it's safe to open Slack again without the OOM killer killing your program or something, if you want to get an answer.
14:50:52
beach
cryptopsy: No, it is not interesting. You really don't want to know. The system will run the garbage collector when it sees fit.
14:51:10
Bike
Sometimes, for optimization reasons, it is important to care about what the garbage collector is doing.
14:51:28
beach
cryptopsy: Manual memory management is one of the main sources of bugs. We are lucky not to have to do that.
14:53:47
sjl_
Out of curiosity: does the spec even require garbage collection? Could a CL implementation just allocate until OOM and still satisfy the spec?
14:54:22
cryptopsy
does clasp compile to llvm ir directly or does it produce intermediate C or C++ ?
14:57:49
sjl_
https://groups.google.com/forum/message/raw?msg=comp.lang.ada/E9bNCvDQ12k/1tezW24ZxdAJ
15:02:38
grewal
cryptopsy: Some lisp implementations expose parts of the garbage collector. See, e.g. http://www.sbcl.org/manual/#Garbage-Collection
15:28:01
cryptopsy
beach: i saw a presentation a chemist made where he implemented his own lisp to solve molecular problems
15:35:32
verisimilitude
An implementation is supposed to signal STORAGE-CONDITION in cases such as memory exhuastion, sjl.
15:44:29
phoe
"In general, the entire question of how storage allocation is done is implementation-dependent, and so any operation might signal storage-condition at any time."
16:05:59
pjb
cryptopsy: Movitz https://common-lisp.net/project/movitz/movitz.html is a CL implementation that runs currently on Muerte, a x86 run-time environment that does not provide a garbage collector. (Movitz is designed to implement operating systems).
16:42:00
beach
housel: There are rumors that he wants to create a new version. And now there is also Mezzano.
16:54:15
beach
cryptopsy: Common Lisp is defined so that the READ function takes a sequence of characters and produces a Common Lisp data structure, which is then further processed by a compiler or an interpreter.
16:55:12
beach
Some people call it that. I don't. It's a Common Lisp data structure made up of lists and atoms.
16:55:42
beach
cryptopsy: Because, as I said, the language is defined to have a standard READ function.
16:56:22
cryptopsy
well it can read the terms and create the linked structure without translating to tokens and then build an AST from a tokenized string
16:58:39
beach
cryptopsy: I am not sure whether you are asking "Why does this particular implementation work like that?", or "Why was the language defined that way?".
17:21:14
verisimilitude
By having READ available by itself, you can easily, say, read in data that has previously been written, cryptopsy. With Common Lisp, you can delay defining a format for serialized data beyond READ and WRITE indefinitely.
17:30:17
phoe
sure, but there is a level when you are somewhat competent with its concepts and workings
17:30:39
dlowe
cryptopsy: okay. We have many, many people who pop in and want to know, abstractly, all about lisp without ever wanting to write a line of code
17:47:12
francogrex
(r% "glm" :formula "outcome ~ predictor" :family "poisson" :offset (r% "as.matrix" (r% "log" (r% "subset" sub :select "doses"))) :data sub)
17:51:39
cryptopsy
how do i disable the header when sbcl runs " This is SBCL 1.5.0, an implementation of ANSI Common Lisp. ...."
17:53:01
francogrex
and it's not really correct what you say dlowe because: (defparameter x (values))
17:54:02
francogrex
while (defparameter xx (r% "glm" :formula "outcome ~ predictor" :family "poisson" :offset (r% "as.matrix" (r% "log" (r% "subset" sub :select "doses"))) :data sub))
17:55:07
cryptopsy
how do i print lines with write when doing (loop for line = (read-line stream nil) while line do ( ...
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