freenode/#lisp - IRC Chatlog
Search
4:53:12
gilberth
didi: OK, if that works for you, the better. But dig the different evaluation times when you have time for that.
4:58:50
PuercoPope
is there any reason to prefer ash vs dpb/ldb when 'buidling' integers from octets? Most code I've found in the open uses ash but I'm inclined to think it is more a more a consquence of familiarity with C
5:00:47
gilberth
And here is why: The exact "subsequence" of bits named the byte is explicitly mentioned in the involving BYTE.
5:13:26
PuercoPope
its also more 'clear'. "I want to put this bytes here" instead of add this number and move them to the right X times
5:14:08
PuercoPope
I was surprised to learn that ldb only works on integeres. Is there a reason why it couldn't work on floats?
5:15:42
gilberth
You also could do, say, (DEFCONSTANT +OPCODE-BYTE+ (BYTE 4 28)) and later just (LDB +OPCODE-BYTE+ X)
5:23:36
gilberth
To answer the original question: Yes, I believe DPB/LDB is "cleaner", but people are just used to ASH/LOGAND/LOGIOR because of C idioms.
5:27:08
gilberth
You were asking, why it wouldn't work on floats. So imagine it would, what would happen?
5:30:05
gilberth
ANSI CL specifically does not stick to any particular float encoding. Even decimal floats are possible. See INTEGER-DECODE-FLOAT or what ever that is called.
5:35:37
PuercoPope
I as unware there were different encoding to floats, in that case it doesn't make sense for ldb to work on floats.
5:36:58
gilberth
Did you imagine for LDB and DPB to work on the underlying bit pattern? Instead of the mathematical value?
5:38:39
gilberth
As in: I have a double --- that are 64 bits --- here and there is the exponent and there is the sign?
5:43:59
gilberth
And then the IEEE format is nuts anyway, I hope we replace it by something more reasonable.
5:48:31
PuercoPope
gilberth: yeah, like single-float had only one representation. But if it is like chars, it is a good idea to not leak the concrete encoding into the rest of the language
5:49:40
gilberth
PuercoPope: Correct. That way to extend the character datatype to 29-bit code points didn't hurt.
5:51:48
gilberth
So, when we make contact to aliens, which have their own 40-bit character set, we could easily extend the character data type with no damage done. :-)
5:54:08
gilberth
Actually I love that. We run code, which is 30 years old or older. And it'll still run in 30 years.
6:00:03
PuercoPope
One problem with old code is loading it. Not all old code used mkdefsystem which translates more or less to ASDF. For example loading op5 in SBCL is not straighforward. But I agree its nice for code not to bitrot
6:01:31
gilberth
Well, that is loading "only". Look at CXML for example. I started to write that some 20 years ago and people still use that. Though I have no idea who maintains it right now.
6:05:59
gilberth
There is still older code out there. I still use lalr.lisp from 1988, initially written by Mark Johnson.
6:07:37
gilberth
Point is: I love that Common Lisp is machine independent. In C an "int" is something different everywhere.
6:10:39
gilberth
That once was a straight 72 hour session to convert from some strange typesetting system to SGML and generating HTML.
6:13:50
PuercoPope
I haven't bothered to learn texinfo and now that you can generate info manuals from Org mode I don't think I'll ever will. Its a pitty because modern documentation tools pays little attention to things like indexes
6:16:36
PuercoPope
It helps w/ autocomplete at the very least. But having indexes is a prerequiste to having proper search
6:17:56
gilberth
What I find more important is the term/concept idea. We have that in the CLIM spec. It says, say, "The argument x must be a foo."
10:01:26
feynhat
I am trying to use this library called "kenzo", which I have installed via quicklisp.
10:03:10
White_Flame
in the SLIME repl, kenzo:<TAB> to see what autocompletes is a good starting point to read
10:10:39
feynhat
phoe, was it really necessary though? I am sure people who are familiar with lisp would have figured this out quickly.
10:39:24
MichaelRaskin
The expectation is that either you defvar/defparameter the variable in advance, or create a local binding with let
11:03:43
jackdaniel
but if we assume that we ask about "potential" function, then question is meaningless
11:04:48
jackdaniel
asdf_asdf_asdf: defvar may be put as part of function body, but it is rarely what you want
11:05:27
jackdaniel
so if you use this variable elsewhere, then compilation will either fail or warn you about undefined symbol usage
11:07:55
jackdaniel
I think that you would benefit from reading some introductory material for programming (and if you have some experience, reading practical common lisp obok)
11:08:01
minion
asdf_asdf_asdf: please see pcl: pcl-book: "Practical Common Lisp", an introduction to Common Lisp by Peter Seibel, available at http://www.gigamonkeys.com/book/ and in dead-tree form from Apress (as of 11 April 2005).
11:22:03
Grue`
minion: memo for didi: you can avoid that with (funcall 'square ,y) because then you're only calling standard functions which cannot be redefined with flet, and 'square takes the global definition of square
14:47:07
dtw
dlowe: Here is my own quick hack that may need further polishing and thinking (function UNESCAPE-C-STRING): http://paste.debian.net/1074448/
14:57:16
vms14
https://stackoverflow.com/questions/48932481/lisp-macros-quotation-implementation-in-javascript
15:02:20
makomo
vms14: what you linked is an implementation of lisp (scheme) in javascript (not an actual feature of js)
15:02:23
vms14
also I want to check if it's true that when you learn Lisp, you'll change as a programmer
15:03:34
beach
vms14: I think your time will be better spent aiming to program sooner in Common Lisp.
15:04:49
vms14
Just need to focus on PAIP and I will, but I'm learning webdevelopment because I'm on a course
15:05:19
makomo
vms14: well, it's an implementation of the backquote mechanism but all of it is at the level of the implemented language (scheme), not js
15:06:39
makomo
it's a cl package/program that takes common lisp code as input and compiles it into js
15:09:13
dtw
pjb: Thank you. Those don't _seem_ to handle \\u and \\U codes but are most likely better than my quick hack.
15:16:11
makomo
pjb: as i learned myself the other day, you should probably handle the case of *READ-SUPPRESS* being bound to T within your reader macros
15:23:26
pjb
Because you're mutating the variable place1, which has nothing in common with the variable x in (let ((x '())) (push2 1 x) x)
15:26:33
beach
asdf_asdf_asdf: So if you understand that C code (you didn't say either way), then you know that add2(234, x) does not alter x.
15:27:19
beach
asdf_asdf_asdf: Similarly, in Common Lisp, if you call push2 with a variable as a second argument, that variable is not altered by the call to push2.
15:28:11
pjb
Instead, use: (defun push3 (item1 place1) (cons item1 place1)) (let ((x '())) (setf x (push3 42 x)) x)
15:29:18
pjb
(setf (aref (gethash :v *h*) (round (* 10 (sin theta)))) 42) this evalautes (gethash :v *h*) and (round (* 10 (sin theta))), but not (aref (gethash :v *h*) (round (* 10 (sin theta)))).
15:30:38
beach
Aruseus: But SETF itself does not evaluate to anything. It is not in a position to be evaluated.
15:32:46
beach
Common Lisp terminology is not very "fault tolerant", so it is important to use precise terminology.
15:38:47
_death
results---the multiple values[2] returned by the storing form for the last place, or nil if there are no pairs.
16:08:09
asdf_asdf_asdf
How change global variable inside function? (defvar *x* 5) (defun aaa (a) (setf a 6)) I want: *x* => 6. How it do? Thanks.
16:09:04
beach
asdf_asdf_asdf: You ask many questions, but you don't like to answer the ones that you are asked do you?
16:09:57
pjb
asdf_asdf_asdf: but actually, have a look at: https://www.informatimago.com/articles/usenet.html#C-like-pointers-in-Lisp
16:10:51
beach
asdf_asdf_asdf: OK, so if you do int x = 5; then void set_global_binding (int a) {a = 6;}
16:12:33
beach
asdf_asdf_asdf: Like C and most other languages, Common Lisp uses "call by value", meaning that argument expressions are evaluated before the function is applied to those values.
16:20:04
beach
asdf_asdf_asdf: pjb's examples are often too sophisticated for someone at your level.
16:22:17
asdf_asdf_asdf
(defun aaa (&treat_as_original a) (setf a 100)) => AAA. (defvar *x* 0) (aaa *x*) => 100 *x* => 100.
16:25:56
beach
asdf_asdf_asdf: Common Lisp has something called "macros" that can be used exceptionally for situations like that.
16:30:02
beach
asdf_asdf_asdf: As a first-order approximation, it is generally a bad idea to have variables in the caller be modified by a function call.
16:38:16
beach
asdf_asdf_asdf: If you tell me your native language, I will check and see if there is an equivalent page.
16:42:26
beach
asdf_asdf_asdf: Why not, there are plenty of smart Polish people here that could help you in your native language.