freenode/#lisp - IRC Chatlog
Search
10:43:21
jmercouris
is there a type of AND macro or form that instead of returning the result of evaluating the last form returns t or nil?
10:44:18
jmercouris
you could of course wrap the AND in a WHEN and have t as the body of WHEN, but that seems a bit clunky
10:54:10
jackdaniel
"you" is implicitly pointing at jmercouris as the person to whom I address the question
10:56:27
jmercouris
I would say about 1/25th of all times I write conditionals do I want it to be explicit that it is a bool
10:56:59
shka_
aeth: thing is that storing is orthogonal to logical operators. You will need to do the same with a lot of functions in multiple places, creating custom versions of each of those is pointless
11:01:45
beach
The only exception I can see would be when some standard Common Lisp function returns a generalized Boolean, such as DIGIT-CHAR-P.
11:03:16
jmercouris
beach: well, in this case I was using a find-if basically to check if some element exists in the list, and it was returning that element instead of a Boolean
11:04:18
jmercouris
I have been thinking about it, and while it is more verbose instead of just leaving it as a find-if, it more clearly conveys intent
11:05:48
jmercouris
I think that would be a bit strange like (defun my-predicate-p (when (and ...)))
11:05:50
beach
jmercouris: If the AND form is in an IF, COND, WHEN, UNLESS or something like that, you will never see the value.
11:06:18
beach
Right, but then my-predicate should only appear in such a position, so again, you won't see it.
11:07:16
jmercouris
_death: SOME and NOTANY are things I have not encountered, and do seem more clear than FIND-IF which is meant to operate on the element if it is found
11:08:59
jmercouris
that's the thing with software engineering and languages, it is so philosophical :D
11:10:01
jackdaniel
jmercouris: difference between and /and/ every is that the latter evaluates all its arguments because it is a function
11:10:06
beach
jmercouris: What I am trying to say is that the return value of AND should only ever end up in a conditional, so then the exact nature of the true value is unimportant.
11:11:24
jackdaniel
this is important distinction if the arguments are forms which have side-effects (or take long to process)
11:14:02
_death
jackdaniel: you're right but note that EVERY will also stop checking if the predicate returns false.. the difference is that AND is connective and EVERY is a (Common Lisp) predicate
11:14:07
jmercouris
jackdaniel: I'm having trouble understanding what you are saying, are you talking about short circuiting?
11:15:12
jackdaniel
jmercouris: try this: (every #'identity (print 1) (print 2) nil (print 3)) and try this (and (print 1) (print 2) nil (print 3))
11:15:24
jmercouris
jus to be clear I'm referring to: https://en.wikipedia.org/wiki/Short-circuit_evaluation
11:17:04
jmercouris
I feel like one needs a degree in LOOP to understand it, like a four year program or something
11:17:47
jackdaniel
when you put enough constructs on top of a hack it becomes standard (see: "posix") ;-)
11:30:40
no-defun-allowed
sbcl's loop implementation has notices from Symbolics and the MIT AI Lab so it's possible
11:33:12
no-defun-allowed
sounds like something Interlisp's CLISP would do though, it let you put meaningless words like `(if (foo-p thing) then ... else ...)` in places to make it more readable
11:58:54
jackdaniel
(so I recommend skipping tl;dr attitude and see what is said by one of the construct authors)
11:59:55
no-defun-allowed
i did read it, must have missed the obvious introduction that pointed out that PG didn't write that
12:00:27
_death
no-defun-allowed: well, I sympathise with both camps :).. I think it's good to be skeptical of both loop/antiloop and clos/anticlos :)
12:00:41
no-defun-allowed
(though "I consider Loop one of the worst flaws in CL, and an example to be borne in mind by both macro writers and language designers." in the parens suggests i'm not wrong, just completely off the point)
12:08:53
_death
consider the premise that object-oriented style is just one possible paradigm out of many
12:11:10
_death
jumping straight to clos, or delving deep into the mop to make it suitable to your problem may not be the most efficient or clear approach to get at what you actually want
12:12:35
_death
of course, sometimes what you actually want brings you to clos/mop, and that's great
12:13:10
jmercouris
granted, you cannot make the argument that it required any changes to Lisp to implement
12:14:09
jmercouris
I'm not sure where I'm going with this, but I cannot imagine Lisp without introspection and CLOS
12:15:19
_death
CL itself due to its history has CLOS almost as an addon.. so it's easy to imagine CL-sans-CLOS
12:15:49
jmercouris
I'm using the expression in the sense of, "it would be very unfortunate", not that I cannot imagine it literally
12:16:14
jackdaniel
it is not said that if there were no "clos" CL wouldn't incorporate other kind of OOP
12:16:14
jmercouris
of course when I was learning Lisp (still learning of course), I did not yet know CLOS and was working without it
12:16:53
jackdaniel
also object orientation and encapsulation are orthogonal concepts, you may write protocol for accessing complex data which has underlying structure in form of a vector whatsoever
12:17:00
jmercouris
I know the other OO systems though, and I don't like them nearly as much, I can't think of an argument for them anymore
12:17:40
jmercouris
sure you can, just how you could drop down into assembler, but abstractions that objects provide make it far easier to persist/access data
12:17:55
jmercouris
and I will disagree with you object orientation and encapsulation are *NOT* orthogonal concepts
12:18:08
jackdaniel
also using clos daily encourages sloppy code where there are dangling methods (and it is hard to follow how the program behaves)
12:18:10
jmercouris
that is one of the big reasons behind Java's different type of class members, they are closely tied
12:18:32
jmercouris
I will not say that one necessitates they other, but I will not say they are orthogonal
12:19:05
jmercouris
jackdaniel: see this section; https://en.wikipedia.org/wiki/Object-oriented_programming#Encapsulation
12:20:04
_death
shka: the funny thing is I remember reading AMOP for the first time and thinking how _simple_ much of CLOS is... :)
12:20:30
jackdaniel
either way I see that you feel very emotional towards clos and oop in general, so I'll just back off
12:21:48
jackdaniel
it is worth noting, that I was speaking about programming techniques (I am aware that every value in CL has its class)
15:53:26
markasoftware
i want to make a macro `with-modulo`. In its body, all basic arithmetic operations should have their results modulo'd. So, (with-modulo 5 (+ 4 2)) would be 1
15:55:03
specbot
Constraints on the COMMON-LISP Package for Conforming Programs: http://www.lispworks.com/reference/HyperSpec/Body/11_abab.htm
15:55:33
White_Flame
you could fiddle with the current package such that + reads as MY-PACKAGE:+ instead of CL:+
15:56:52
White_Flame
in SBCL you can unlock the CL package and fiddle with things like that even if you're not supposed to
15:57:38
Xach
In this case I think it would be appropriate to use a code walker but I do not know how easy or difficult that would be.
15:58:11
_death
markasoftware: suppose you move (+ 4 2) to some function and call it in WITH-MODULO.. should it return the same result?
15:59:22
White_Flame
it's not that different; the difference is that the CL package is effectively locked
15:59:28
_death
markasoftware: then as Xach said, one way is to use a walker.. if you like to live dangerously you can SUBLIS :)
15:59:44
markasoftware
so, a walker would look through the forms in &body for any + to replace them?
16:01:06
White_Flame
plus, distinguishing between vars, function calls, etc in all the lisp-2 scopes is more difficult in a manual code walk
16:01:46
markasoftware
i think i'll just take the easy route and use different functions for modulo arithmetic and normal arithmetic. Thanks for the insight!
16:02:19
White_Flame
yep. It is often a pain point that the standard functions are not extensible or generic functions
16:03:31
aeth
And the standard functions that are generic are a special kind of generic, not generic functions
16:05:05
lavaflow_
hey dumb question, but which software license is generally prefered by the lisp community?
16:05:29
lavaflow_
I was thinking, the most popular editor seems to be emacs, so maybe the lisp community likes the GPL too?
16:08:42
ckonstanski
Yesterday I asked about getting a lisp process to run in docker. Turns out the problem is not with lisp but rather with docker, and the solution also lies within docker. Add -t to the docker run command line to get a pseudo-TTY.
16:09:39
aeth
Xach is probably the only one who could quantiatively tell you (1) how many projects are under a certain license and (2) if that trend has changed over time based on first commit in the repository.
16:09:51
ckonstanski
The REPL cannot exist without a TTY, and therefore the lisp image dies as soon as it wants to land at the REPL.
16:11:35
_death
could be there are a massive number of proprietary projects that you never heard of :)
16:11:38
Bike
your lisp probably has an optiona to run something else instead of the repl, if that's the kind of thing you want to do
16:12:56
aeth
You probably need to create a file to be run specifically for this purpose since it will call your main or whatever, which you wouldn't normally do automatically from the REPL.
16:13:11
Xach
_death: that is one reason why i don't like an attitude like "I will break my interface and send patches to all projects that break" - how can you know what breaks below the surface?
16:13:37
ckonstanski
--non-interactive makes the problem worse. Lisp exits as soon as it finishes loading and running whatever is in thte --load (or --userinit or whatever) parameter.
16:14:30
ckonstanski
If you're trying to run a hunchentoot web server (for instance) that listens in the background, you have to keep the image alive after it'S done loading.
16:14:37
aeth
ckonstanski: you probably want a loop to keep it alive, with a way to quit it, and a way to access it via swank, using an ssh-tunneled SLIME
16:15:04
Xach
_death: I don't mind a justified breaking of interfaces, but I find the idea that it is mitigated substantially somehow by sending patches around not great.
16:15:43
_death
Xach: definitely.. that is a very important pro for CL, that it's stable.. although when what you say happens I'm sometimes ambivalent because I believe the ecosystem is still small enough for it to make sense if the interface is very broken
16:20:12
Xach
I remember one message from the "big 5" standardization list: "I'd rather piss off a thousand RMSs than one MCC", which is not exactly my sentiment, but it is slightly related.
16:23:16
White_Flame
ckonstanski: this is no different than a server in any other language. There's a "main thread is finished" behavior or equivalent that exits the program, that you need to block on
16:25:09
aeth
ckonstanski: You can do something like this: (defun main () (loop :until (zerop (random 10)) :do (sleep 1/10))) (main)
16:25:46
_death
Xach: hah.. don't release internal code so that customers won't use internal interfaces... :)
16:26:38
_death
Xach: I think I have some projects that I don't put up for that reason, amongst others ;)
16:53:44
markasoftware
i want to generate functions which are named +m, -m, *m, and /m, slightly modified versions of all the built-in arithmetic
16:54:56
Xach
markasoftware: ok. you can get the name of a symbol as a string with (symbol-name symbol)
16:56:33
Xach
symbol names that appear in sources as lowercase are by default read into lisp as uppercase, so if you make a symbol with a name of "m+" it will print funny, but it won't if you use "M+".
16:59:26
White_Flame
neither of these will perform the read-case transformation, though. read-from-string can convert a string to a symbol, with the case transformation, *IF* it reads as a string
17:01:15
White_Flame
oh, the alexandria library also has SYMBOLICATE, which is handy for building up symbols from parts
17:06:46
Bike
you can just try intern and symbol-name and stuff in the repl to get a feel of how they work
17:15:15
pjb
markasoftware: if it's whatever, why do you care giving it a name? Just (lambda ,lambda-list ,@body).
17:16:10
pjb
(intern "name with smaller case, and other <strange> \"characters\" and stuff.") #| --> |name with smaller case, and other <strange> "characters" and stuff.| ; nil |# works too ;-)
17:18:12
oni-on-ion
hmm " and | need to be different? ie. why wouldnt symbols and strings have more 'equality'?
17:20:13
pjb
oni-on-ion: it's possible. The first LISP used commas to separate tokens. (foo |bar baz| quux) was written (FOO,BAR BAZ,QUUX)
17:21:03
oni-on-ion
i notice that hemlock (and clim listener?) use space for completion. (also it uses Real Word Command rather than real-word-command)
17:21:55
oni-on-ion
in a way looking back, it could make sense as we-use-hyphens-for-spaces-instead nowadays
17:22:42
_death
I'm reminded of those javascript testing frameworks with it("should not break too hard", function() { ... })