freenode/#lisp - IRC Chatlog
Search
15:34:54
Ukari
show me the example about `define dynamic variable and create dynamic context for these functiosn with let`, it sounds interesting
15:37:09
jackdaniel
(defvar *foo*) (defun init () (setf *foo* (make-hash-table))) (defun ukari-get () (gethash …)) (ukari-set () (setf (gethash …)))
15:37:53
jackdaniel
in body of this let form *foo* is bound to nil, outside this let form *foo* is not bound at all
15:43:33
jackdaniel
we could go on with improving your hack, but readable solution is to have argument to your set/get functions
15:44:05
pjb
Ukari: I would distinguish inner-loop functions from public API functions. The later, notably if they're intended to be invoked from the REPL, as commands, can have all kinds of sophisticated argument parsing, including &key and others (eg. catching additionnal arguments or list of arguments after the last &key, which is not parsed by default). But for internal functions, it may be better to use more plain lambda-lists, with only
15:44:25
jackdaniel
having dynamic context, or even worse – floating anonymous functions, makes your program hard to analyze
15:44:40
pjb
Ukari: and for results, multiple-values are probably the fastest way to return multiple values, even if you put a lot of NILs there for optional results.
16:47:56
Ukari
(iterate (for i in '(1 2 3 4)) (print i)), why this code tells 'The variable I is unbound'
17:08:58
foojin
jackdaniel: In your answer to Ukari, what did you mean by "floating anonymous functions"?
17:11:14
jackdaniel
each of them was not named, and I assume he would want to store them *somewhere*
17:12:43
Ukari
nameless lambda don't make global name confit but defun does, or it needs package name provided
17:12:44
foojin
jackdaniel: Ah, so it's just about passing them around so that it becomes difficult to know where did they come from.
17:13:45
phoe
Ukari: do you really need to generate code for each single hash element that you have?
17:13:56
jackdaniel
Ukari: I suspect you are a beginning CL programmer. I may be wrong, but if it is a case, you may learn a lot by following simple advices
17:14:13
phoe
and each single hash value is going to have a completely separate function that is going to be called?
17:15:08
jackdaniel
it is easier to maintain N variables with your "instances" and use directly gethash/setf gethash, then to maintain 3xN functions doing that for you
17:15:30
jackdaniel
if you have more complicated behavior, you maintain objects in variables and you specilize generic functions on their classes
17:15:45
Ukari
maybe i could store nameless lambda in a static way and pass varibale into it, like (let ((set (lambda (store) (lambda () ...)))) (defun hash () (list (cons :set (funcall set store)))))
17:15:48
jackdaniel
etc, that is something what people do, because it works and it provides easy structure of your program to follow
17:16:24
jackdaniel
but I think you are not interested in following this "nonsense", so I'm getting back to my Saturday ;-) see you \o
17:17:43
phoe
Ukari: grab a CLOS tutorial, read it and use it. You're going in a direction that is rarely used (because better mechanisms exist) and insanely hard to debug.
17:27:57
Ukari
i find a not-independent generator in this code, (iterate (for el in '(1 2 3 4)) (generate i from 1) (print (next i))). is there any standrad about independent generator?
17:30:21
phoe
Ukari: I think the only piece of manual for ITERATE is https://common-lisp.net/project/iterate/doc/index.html
17:41:15
Fare
Ukari: if you're heavy into functional style and going below the object system, Scheme might be more for you than CL.
17:52:17
fourier
not exacly lisp question but rather slime/sly, but how to get the last value returned in repl? like (sly-inspect "*") always inspects nil
18:01:38
fourier
what I want is to call sly's graphical inspector on *. but it always inspects nil :(
18:10:00
rme
Fare: The funding situation is not good. I have done a little paying work for about 1.5 clients.
18:21:22
rme
Thank you, phoe. I know there are generous people out there like you, but I have some doubts about whether crowdfunding is suitable for sustaining funding for a software system like CCL.
18:24:11
Fare
I have fond memories of working with CCL. A few issues, too, but overall minor. Not sure how things changed since Gary retired (how is he?)
18:24:56
phoe
rme: I honestly don't think it's going to sustain CCL but I nonetheless want to throw my two cents at it the moment I have a chance.
18:26:04
rme
He's mentioned to me before that he thinks about getting back on the net, but I don't know much more than that.
18:27:10
Fare
(I still believe ITA did the wrong call on dividing its attention between SBCL and CCL, but that is one of the least mistakes made there)
18:54:24
Fare
coming back to it, I find I enjoy having decent type inference to help me. The syntax is annoying. The build system story is in disarray though with a good solution in sight (jbuilder / dune); the metaprogramming story is well, quite unsatisfying though not quite as bad as Java.
18:57:34
Fare
Types do help a lot with prototyping. And library support for pure functional programming.
18:57:51
rme
I've always sort of been interested in ML and OCaml, but I've never used either for anything real.
18:58:02
jmercouris
you are a much more experienced developer than me though, so maybe with time I'll achieve some level of enlightenment in this regard
18:59:23
Fare
I do find that OCaml is a bit awkward in that anything serious requires using modules which require one more level of complexity compared to other things. I miss the seamless ad hoc polymorphism of Scala or Haskell.
19:00:14
Fare
fourier, because we wanted to work with Tezos (shelved for now) which uses OCaml, and we still want to use with Coq, which has much better OCaml than Haskell support.
19:01:41
Fare
Also, unless I had an expert Haskell partner, I wouldn't feel comfortable using Haskell. OCaml lets you easily escape to plain old imperative style, so I know I can fallback to the bad old ways if needed.
19:06:06
jmercouris
prolog is way too imperative, that's a statement I never thought I would hear :D
19:10:31
jmercouris
sure, anyone that's serious about a business is usually using an advisor as an avenue to investment
19:17:09
loginoob
I am a beginner, have only read 6 chapters of CL:a gentle introduction. Should i also learn to write tests to my programs or that should be learned later?
19:17:35
jmercouris
loginoob: Tests aren't super critical, plus there is no "de-facto" testing framework in CL
19:18:20
jackdaniel
loginoob: desiging tests for your application is essential, but not so important for learning excercises
19:18:53
jmercouris
loginoob: You can find it here: http://www.gigamonkeys.com/book/practical-building-a-unit-test-framework.html
19:19:09
jackdaniel
loginoob: tool you use to write tests is a secondary choice, we have multitude of testing frameworks but a little number of tests written
19:19:11
Fare
even cooler than designing your own test suite, is not doing it and helping cleanup the test library situation.
19:19:54
phoe
loginoob: I suggest that you try reading the code for 1AM and trying to use it for your first tests.
19:19:56
jackdaniel
creating new test framework won't help picking the leader ,) I fully agree with Fare
19:20:12
phoe
it's a test framework that fits on a single page of paper and is therefore dead simple to understand.
19:21:39
phoe
because 1AM is a fun wrapper around DEFUN that also takes case of collecting all tests for the purpose of running them together.
19:24:08
loginoob
I guess i should focus on learning CL and worry about tests after i become intermediate
19:44:50
fourier
first learn the language, tests you will need then you are about to write some library/app in it
20:18:50
foojin
How can variable capture occur in the following example macro from "On Lisp": (defmacro cap2 (var) ‘(let ((x ...) (,var ...)) ...)) ?
20:20:38
foojin
It's not specified. I suppose that whatever's in there, it contains instances of ",var".
20:25:20
foojin
phoe: Wouldn't your example expand to nested LETs? BTW that's what I meant when I wrote about a "LET error".
20:30:03
foojin
So, if one were to suppose that only correct (non-malformed) expansions will occur, there's no way for x to be captured, is it?
20:32:24
shrdlu68
p_l: I've been thinking about the language-agnostic-syscalls thing, reading up on kernel hacking, procf, etc.
20:38:30
shrdlu68
Ah, so :cl-user :uses :sb-ext, which is why I've always been able to call gc without the sb-ext: prefix.
20:44:23
pjb
foojin: more precisely, it's because in (let ((x 42)) (cap2 x)) we want the x in (cap2 x) to refer to the x bound by let. but the macro cap2 could expand to (let ((x 33 #|for example|#)) '(list x)) #| --> (list 33) |# where is bound in the inner let. This is not inherently wrong. It's just a matter of specifications of the cap2 macro, and of general expectations ("style") in CL.
20:45:03
foojin
phoe: The question was somewhat ambiguous, with dots instead of actual code, so I assumed there were no comma substitutions there. Otherwise that situation would surely be possible.
20:45:44
pjb
foojin: If you are defining a specific DSL, perhaps it's meaningful for the x in (cap2 x) to be refering something else than outside bindings. But if not in this case, it's generally expected that the in a form such as (let ((x 42)) (cap2 x)) the x in (cap2 x) be a lexical reference to the lexical binding.
20:47:13
pjb
It's often better to let the user specify the name of the inner variables, when he can also provide bodies or expressions refering them: (let ((x 42)) (cap2 (x) x)) would then read similarly to (let ((x 42)) (let ((x 33)) x)) and there would be no contraried expectation: it would be clear, lexically, that cap2 establishes a new binding for x.
20:47:42
pjb
And if the user wants to use the outer x, this allows him to write (let ((x 42)) (cap2 (y) (+ x y))).
20:49:23
pjb
shrdlu68: I have this in my common.lisp rc file: (mapc (lambda (package) (unuse-package package "COMMON-LISP-USER")) (delete (find-package "COMMON-LISP") (copy-seq (package-use-list "COMMON-LISP-USER"))))
20:49:41
pjb
shrdlu68: so my CL-USER is the same in all implementations, and I can write conforming code even in CL-USER.
20:50:18
foojin
pjb: I totally forgot about the "expectations" thing. It would indeed be quite strange for an inserted binding to get in the way (as shown in your first example).
20:50:33
pjb
puchacz: (subseq (com.informatimago.common-lisp.cesarum.file:binary-file-contents "/etc/passwd") 0 10) #| --> #(35 35 10 35 32 85 115 101 114 32) |#
20:51:57
pjb
foojin: this is why it's not wrong per-se. It all depends on the specification of the macro. For example, anaphoric macros establish an implicit binding to IT.
20:54:15
phoe
If an external symbol of the COMMON-LISP package is not defined as a standardized function, macro, or special operator, it is allowed to lexically bind it as a function (e.g., with flet), to declare the ftype of that binding, and (in implementations which provide the ability to do so) to trace that binding.
20:57:30
pjb
This is a strong exception for the implementations, because the default rule is that implementations can define functions for those symbols. But then they cannot use directly those functions in macroexpansions, because that could be wrapped in a flet/labels that would shadow them…
20:58:53
phoe
because with the symbol UNSIGNED-BYTE being exported, that would mean that the symbol UNSIGNED-BYTE is now globally fbound.
20:59:15
phoe
And it must NOT be globally fbound because there is no standard function CL:UNSIGNED-BYTE in the standard.
21:00:17
pjb
but 11.1.2.1.2 pt. 2 is generally explained saying that implementations may do just that.
21:00:53
pjb
Notice that in the exception it's not said "if the exported symbol is fbound or not" but "if the expected symbol is DEFINED by the standard as a function."
21:01:37
pjb
file:// works too, such as file:///opt/local/share/doc/lisp/HyperSpec-7-0/HyperSpec/Body/m_ignore.htm
21:02:13
phoe
It's nonetheless weird for me that the standard would permit a thing like #'UNSIGNED-BYTE.
21:02:46
pjb
phoe: not really. This allows implementations to use functions to represent things such as types.
21:03:35
varjag
so M-x hyperspec-lookup works for me if i set the root to a web adress, but not with the local hyperspec repo
21:05:02
phoe
I wonder if it has any constrains about whether some of these symbols must/must not be bound/fbound/macrobound.
21:05:25
phoe
I mean, if the list of all fbound external CL symbols is not permitted to be extended by the implementation above the bare minimum.
21:56:41
Ukari
is (defstruct ship ..) must use a 'make-ship' to make a instance? Is there anything like (make-instance 'ship ) also works ?
21:58:45
Josh_2
Hmm I wonder when Fare is gonna come back, there is some questionable English on his site
22:12:04
pjb
Notice that since you're asking for number: (ldb (byte 32 0) (round (realpart #c(-3.0 0.0)))) #| --> 4294967293 |#