freenode/#lisp - IRC Chatlog
Search
0:59:58
eschulte
aeth: thanks! I can at least write-bytes to the input stream of a process started that way.
1:16:36
eschulte
Yeah, launch-program works well. The only downside being that (as opposed to SBCL) I have to decide when creating the process if I want to write characters or bytes
5:02:30
no-defun-allowed
<beach> http://www.lispworks.com/documentation/HyperSpec/Body/f_float.htm actually
5:02:51
beach
gabbiel: It would be much better if you tell us what you want to do, rather than referring to a different language.
5:03:37
gabbiel
I was going to click on link but pressed the kill window keybinding instead by accident
5:04:14
loke`
if you want to convert to a specific float type, you can use (COERCE 1/3 'DOUBLE-FLOAT)
5:09:07
loke`
gabbiel: It implements it by using rationals behind the scenes, and then provides a custom reader/writer and some other syntactic sugar to make it nicer.
5:10:08
loke`
it contains functions for converting them to/from strings as well without losing precision.
5:10:54
loke`
In most cases I personally just use raw rationals. I rarely have to read or write them.
5:11:07
gabbiel
I do all my arithmetic with ratios, and now I have to convert to decimals for this function I have
5:12:42
gabbiel
the function in question outputs grams, so I need the actual decimal so I can properly mix my stuff
5:14:37
gabbiel
but first I need to write a subst-if like of function so I can find the ratios in the tree
5:16:13
gabbiel
I'm printing the whole tree you see, if they're floats already, I don't need to calculate where they are and then print them
5:17:57
gabbiel
since the tree is a list, and also contains symbols, I can't do that. I'll have to settle for subst-if 'ing the numbers into floats and then printing the tree
5:20:20
gabbiel
but I wouldn't want this printing behavior to be permanent, only when my function is running
5:22:24
gabbiel
ok, I see, thanks guys, I'll use this pprint-dispatch stuff, apropos has helped me figure out the functions I need to make the behvaior temporary
5:23:56
beach
This would have been much easier if it had started with "I have a tree represented as a list, and I want to print the whole thing normally, except when the leaf is a ratio, because then I want it to print as a decimal.".
5:26:28
beach
Yeah, well, I am also notorious for not understanding descriptions like that. LdBeth caught it.
5:30:18
gabbiel
ldbeth: correct me if I'm wrong. Do I have to copy-print-dispatch, then set-pprint-dispatch, then setf *print-pprint-dispatch* back to the copy?
5:32:38
gabbiel
lmao I thought I could "cons" a "pprint-dispatch" object or something, but I know it's not a list
5:35:35
LdBeth
gabbiel: the sad thing is the actual implementation of pprint table can vary, so what you have is the things specified in the standard, copy the default pprint table then modify it
5:39:46
gabbiel
I feels lik there should be a macro that returns a variable to the value it had when the macro was expanded
5:50:00
pjb
gabbiel: however, you can write (eval-when (:compile-toplevel :load-toplevel :execute) (defvar *voo* 42)) (defmacro moo (var) `(setf ,var ,(symbol-value var))) (progn (setf *foo* 33) (moo *foo*) *foo*)
5:50:41
pjb
gabbiel: macros, functions and special operators are operators, and operators can be "applied" (not with apply, but still) or "invoked".
5:51:25
pjb
gabbiel: note how you have to put the value of the variable in the compilation environment, using eval-when.
5:51:54
pjb
gabbiel: if a macro requires that you write some boilerplate around it, then it's a bad macro.
5:52:11
beach
LdBeth: Also the CLIM specification: http://bauhh.dyndns.org:8000/clim-spec/index.html
5:53:15
pjb
gabbiel: instead, I would propose a macro to define both the variable and a resetting function.
5:54:15
pjb
or two macros, one global, and one lexical: (define-resetable-variable *foo* 42) (reset *foo*) (let-resettable-variables ((foo 42)) … (reset foo) …)
5:54:16
gabbiel
makes sense, no wonder it hasn't been written, even it though it seems a good idea at first
5:56:29
pjb
Perhaps something like: (defmacro define-resetable-variable (name value) `(defparameter ,name ,(setf (getf 'initial-value ',name) ,value))) (defun reset-variable (name) (setf (symbol-value name) (getf 'initial-value name)))
5:56:42
gabbiel
but when the function runs, surely the var will have a value. also, why couldn't it work onormal vars
5:57:03
pjb
gabbiel: the problem with lexical variables, is that their name disappear once compiled.
5:58:15
beach
LdBeth: Here is one paper, but that's not the one I am thinking of: https://www.researchgate.net/profile/Ralf_Moeller5/publication/246460414_User_Interface_Management_Systems_The_CLIM_Perspective/links/545b53940cf28779a4db0700.pdf
6:00:02
gabbiel
this is confusing, I didnt know this would be a problem: (let ((val var)) body (setf var val))
6:04:01
beach
LdBeth: I have a specific paper in mind, but I can't seem to find it now. Maybe I dreamed it up.
6:20:10
pjb
gabbiel: if you want to restore a variable after usage, perhaps you want to use unwind-protect too?
6:21:30
pjb
Actually, we'd need more than a paste service. Well, for short throwable snippets, ok. But often we have more complete code, that can be referenced years later. So perhaps something like codeshare.io
6:25:08
gabbiel
but pjb's solution is more general, allows for resetting whenever you want, that's nice
6:25:18
pjb
gabbiel: what if an error occurs in body? Do you want to keep the modified value or do you want to restore the old value?
6:36:45
pjb
works on places. but foremost, it uses unwind-protect to restore it even if body makes a non-local exit (error, return, throw, etc).
6:44:19
gabbiel
I was also going to write a save-variables macro, or in your case, a save-places macro, I guess it'd be easy to implement by just having a places and &body arg
7:07:41
pjb
minion: memo for gabbiel: the &environment parameter is required to handle things like (let ((x 42) (y 33)) (list 'outer (symbol-macrolet ((y x)) (list 'inner (save-place (y) (setf y 0) (list x y)) (list 'mid x y))) x y)) #| --> (outer (inner (0 0) (mid 42 42)) 42 33) |#
9:42:14
beach
I don't see anything that requires IGNORE to be a closed declaration, but it won't work anyway, because in the scope between the two LETs, it is still not referenced.
9:47:07
jdz
fivo: Yes, that's why I said "maybe", because I don't know why you'd want to do what you're doing at the moment.
11:51:27
schweers
fivo: do you know of metabang-bind? https://common-lisp.net/project/metabang-bind/user-guide.html
11:51:27
minion
schweers, memo from jkordani: did you figure out what was going on with your code coverage issue?
11:51:58
schweers
jkordani: sadly no, other than that it seems to have problems with some code. For instance with lparallel.
12:31:55
prxq
I'm trying to use slime to edit and run code on another machine (a windows one). I'm having trouble with the slime-tramp extension. Specifically,
12:33:22
prxq
the problem is that I use the cygwin ssh server, and the path to the windows file C:\this\file.cl will be /cygdrive/c/this/file.cl.
12:34:32
prxq
Anyone knows how I can insert the /cygdrive/c/ part into a SLIME-FILENAME-TRANSLATION?
12:36:45
pjb
prxq: emacs lisp is case sensitive and doesn't have a readtable to upcase or preserve it!