freenode/#lisp - IRC Chatlog
Search
8:39:20
antoszka
beach: is that editor of yours already available for checkout/building/testing anywhere?
8:43:41
beach
Yes, but I have separated the GUI from the rest as much as possible, so it ought to be possible to use something else.
8:45:21
Shinmera
I know that the expansion of macros can happen multiple times, and I distinctly remember reading that in the CLHS, but I can't find it for the life of me
8:45:23
beach
CLIM/McCLIM makes so many things much simpler, though. I can't see myself re-implementing things like presentations for a different toolkit.
8:45:53
beach
Shinmera: Yeah, I know exactly what you mean. It is always very hard to find such things.
8:49:55
jackdaniel
yes, but I don't think that it is a must for a decent book to mention this particular thing
8:50:23
jackdaniel
for instance I don't think I've encountered such statement in CL Recipes, yet I think it is a very decent book
8:54:58
phoe_
Shinmera: https://github.com/xach/dpans/search?utf8=%E2%9C%93&q=%22multiple+times%22&type=
8:55:14
phoe_
I've been grepping the dpans3 sources for "multiple times" and were unsuccessful so far.
9:02:53
phoe_
"Macros intended for use in top level forms should be written so that side-effects are done by the forms in the macro expansion. The macro-expander itself should not do the side-effects. "
9:10:42
Shinmera
I mean, it's implicit in the sense that the spec never says that it is only expanded once either.
9:15:31
phoe_
Basically, edit-time will be equivalent to compile-time then, since macros will need to be expanded, so their macro functions will need to be called.
9:16:28
phoe_
Gah, this problem is an issue of type "can God create a stone too heavy for him to lift".
9:17:01
phoe_
We got a language powerful enough to turn its source code into Brainfuck and we're looking for an even more powerful tool to handle its power.
9:44:56
eminhi
from clhs prog2 description: prog2 evaluates first-form, then second-form, and then forms, yielding as its only value the primary value yielded by first-form
11:04:54
dim
is it safe to conclude they already had copy/paste at the time when writing the spec? ;-)
11:53:14
pjb
So it probably pre-existed unix ed, after all, unix is but a simplified clone of older systems and software…
12:51:05
pjb
shka: you have to look at early computers. Later, punched cards were copied first on an input spool tape (using a secondary computer), before being fed to the mainframe.
13:56:41
pjb
shka: the thing is that they were built with strong material. Like 5 mm steel. Just like a tank!
14:06:30
Josh_2
In On Lisp there are two examples as shown in this paste http://paste.lisp.org/display/358509 where one function takes a variable x as an argument to a function and that variable is considered bound, and then another example which takes the variable n as an argument to a function but that variable is considered free. This seems contradictory, is it?
14:08:46
mxb
Hi all. Anyone have experience with binary-types package? I'm struggling to try to define a binary-struct which references an earlier field and I'm not sure if it's possible to do so. (Basically parsing {type,length,data[length]} blobs
14:09:11
beach
Josh_2: Because it is used in a function, but it is not a parameter of that function.
14:11:44
mxb
phoe_: I'm learning binary-types with PNG file format - my code is here http://paste.lisp.org/display/358510
14:12:08
mxb
PNG spec is here if it helps: https://www.w3.org/TR/2003/REC-PNG-20031110/#5Chunk-layout
14:13:43
phoe_
I never used binary-types myself, but hopefully someone up there can take a peek at your code.
14:14:45
mxb
phoe_: yes, during macro expansion of define-binary-string size is LENGTH, which is not of type (INTEGER 1 *)
14:21:32
phoe_
Since this a macro, then SIZE must be an integer before its evaluated - so it cannot be a variable.
14:22:00
Bike
oh, so this isn't gigamonkeys's? i'm pretty sure his could do that, since it's so common for binary formats
14:23:47
mxb
phoe_: Yes, it seemed like there are signed/unsigned binary integer types, and 'strings', which I took to be arbitary lengths of data
14:26:09
Josh_2
I don't particularly understand lambda calc just like I don't understand normal calculus. However I found this sentence "The abstraction operator, λ, is said to bind its variable wherever it occurs in the body of the abstraction."
14:27:06
Josh_2
I'm sure if I put some serious effort in I could learn some Lambda calc just like I could with normal calculus
14:27:12
Bike
well, and i suppose integration and differentiation can involve binding variables and so on
14:27:28
beach
Josh_2: The concept of free variables is very important to the compiler writer, because, in general, they can't be treated as simply as bound variables can.
14:28:13
phoe_
And I'm sorry that I can't help in this case. Maybe the library Bike suggested can deal with that.
14:33:32
phoe_
I wish I had a #lisp full time job so I could spend all of my time and all of my attention on refining CL documentation and libraries. There's so much to be done in Common Lisp world and I am doing corporate dung instead.
14:34:53
Josh_2
Save some money, buy a van, live in the van using mobile internet and a laptop for 6 months of the year.
14:37:38
Josh_2
Well I have a motorcycle so takes me 10 min to get to Uni. I guess you went to a much better Uni than mine if you need to prep for a class
14:38:17
phoe_
Just doing homework takes time, and sometimes there's a lot of homework needed before I get some programming or math concept.
16:10:51
Bike
you could also define a package that shadows cl:close; might or might not make sense for you
16:12:56
phoe_
or make your defcfuns inside a different package that either does not :use CL or shadows it CLOSE symbol
16:21:34
jackdaniel
if test *evaluates* to true, true is evaluated and result of this evaluation is returned
16:29:58
Josh_2
dlowe: I gave (set t nil) a shot and got Simple Error Veritas Aeterna or Eternal Truth
16:35:38
Bike
huh, define-symbol-macro isn't defined to have any compile time effects. weird oversight
16:59:54
Bike
no, sizeof is not an operator available at runtime. you can use something like grovel to keep that information
17:15:52
phoe_
when you dereference a pointer, you tell CFFI what you expect to have underneath that pointer - if it's an int, a float or a structure of type X
17:16:24
emaczen
phoe_: Ok, I think I see my mistake in reading the C code then -- that makes sense too
17:16:31
phoe_
you don't declare the type when you grab a pointer, you declare the type when you dereference it.
17:17:54
phoe_
pointers are simply numbers after all, uint32 or uint64 depending on architecture. CFFI uses exactly this philosophy.
17:18:34
osune
while we are at CFFI, somebody knows a library for libevdev? I still have quite a hard time to wrap my head around cffi to do it myself but if there is nothing I'll have no other option then to do it myself
17:18:37
Bike
i'm not sure if a c implementation is allowed to use different representations for different pointer types
17:20:37
jackdaniel
cffi store more exact information about pointer type, but what implementation gets is indeed just :pointer
17:21:29
phoe_
jackdaniel: a pointer is a value, a memory offset, which is a number - am I wrong here?
17:22:43
Bike
you can allocate a block and use arithmetic on pointers in that block, but as soon as you go outside it's UB land, iirc
17:25:06
jackdaniel
but if it were just a number, than uint foo = my_ptr; foo++; my_ptr=foo; should yield in the same thing as my_ptr++
17:25:59
jackdaniel
but if it doesn't, you come into bigger trouble. so there is a good reason for error ;)
17:26:20
dlowe
jack_rabbit: uh, not true. The amount my_ptr is incremented depends on the size/align of the underlying type.
17:30:18
jackdaniel
also I'm not sure, but I have a suspiction that there is no mention in C standard, that pointers are numbers at all
17:31:41
dlowe
but yeah, the only guarantee is that you can cast a pointer to a number and back and get the same pointer
17:34:56
jackdaniel
well, you can't (portably), because you don't know if pointer will fit in any integer you have
17:40:37
tax
does having multiple namespaces in common lisp yield a major benefit over lisp-1 languages? why do even popular industry languages like clojure use/choose a lisp-1? seems like namespaces would be useful. what am i missing or not understanding?
17:41:20
_death
pointers are numbers in the same sense that "everything is a number".. what is usually meant is that they can be represented as numbers.. there are some gotchas for the unwary, though.. for example the null pointer (0) may not be represented as all-bits-off numeric zero
17:41:41
phoe_
tax: lisp-1 languages are usually pretty heavy on functional programming, and Clojure is not an exception here
17:42:39
phoe_
CL has multiple namespaces actually - variables/symbol macros, functions/macros, classes/conditions/types, restarts... and the user can create and define their own ones
17:44:12
phoe_
when you're heavy on functional programming, you might want to use a shortcut where e.g. FOO always means a function
17:46:05
phoe_
(defun ensure-list (list) (if (typep list 'list) list (list list))) <- hey, that's five LIST symbols next to each other, not counting parens and quotes
17:47:21
phoe_
but then again, I'm not a Schemer - I'm used to CL so I can mostly tell you the CL viewpoint.
17:48:38
phoe_
dlowe: write a blog post about it and post it on /r/lisp so we can reference it for the future.
17:55:41
Bike
check it, i googled "python optional" and this appeared http://www.diveintopython.net/power_of_introspection/optional_arguments.html
18:04:37
emaczen
I keep getting this error: The value (S-ADDR 31235) is not of the expected type CCL:MACPTR. -- http://paste.lisp.org/display/358528
18:04:58
emaczen
I have no idea why, the slot wants a :uint32 and that is exactly what inet-addr returns
18:05:23
sjl
or are you just saying use &rest and manually process the arglist in the function body myself?
18:07:22
Bike
so you could use foreign-slot-pointer to get a (:pointer (:struct in-addr)) instead, and then get the s-addr from there
18:07:24
_death
sjl: anyway, python also has thing sillyness of evaluating the default forms once at definition time, no?
18:07:48
emaczen
Bike: I just changed the inner cffi:foreign-slot-value to cffi:foreign-slot-pointer
18:08:21
pjb
So it really has optional parameters, and keyword parameters, etc, just like CL. You just need to implement a library using stdarg.h
18:09:32
SaganMan
ohh, just googled https://stackoverflow.com/questions/19212040/how-can-i-make-a-function-with-optional-arguments-in-c
18:11:07
SaganMan
but pjb, can all arguements in a fuction of C be optional? don't you get "too few arguements"
18:12:04
pjb
SaganMan: of course, you need to have a way to indicate the actual number of arguments.
18:17:17
pjb
_death: CL functions can return multiple values, so you cannot use result=f(), but you have to use f(…,&results)
18:17:33
_death
pjb: the caller builds up the &rest list.. you could then define one function to call them all, apply(symbol("add"),list(...))
18:18:09
pjb
So you have to write: list(3,number(3),number(2),number(1),&results); apply(2,add,results[0],&results);
18:21:01
Xach
phoe_: do you understand the problem in http://report.quicklisp.org/2017-10-12/failure-report/asd-generator.html#asd-generator?
18:30:46
haom
hello, what is the way to format variables into strings by their names, like "My name is $name." => "My name is Mike."
18:42:53
pjb
Lisp in Small Pieces http://pagesperso-systeme.lip6.fr/Christian.Queinnec/WWW/LiSP.html http://pagesperso-systeme.lip6.fr/Christian.Queinnec/Books/LiSP-2ndEdition-2006Dec11.tgz
18:42:57
emaczen
You can find several and I think pjb is referencing John Mccarthy's original paper, which is on that site too
18:43:19
_death
aeth: no, it is modelled on principle of Lisp - use Lisp conses and atoms for structured information
18:44:02
emaczen
http://paste.lisp.org/display/358528 -- see anything wrong with my defcstructs? I'm getting ERRNO=47, EAFNOSUPPORT
18:44:09
aeth
_death: Your out example looks like `cout << "My name is " << name << ".";' except more concise because you don't need to use <<s
18:52:55
phoe_
Xach: the freshly cloned github.com/phoe/asd-generator compiles on my machine on ASDF 3.2.0.1
18:58:32
rumbler31
Xach: my machine crashed while I was in the middle of running update-all-dists. It was in the middle of downloading updated packages so I'm pretty sure it didn't finish. Is there a way to "restart" this process?
19:03:57
_death
aeth: here's another example, introducing a "recent" addition for printing hash table contents.. (let ((ht (plist-hash-table '(two 2 forty-two 42)))) (outs (:dc (:h ht (k v :separator ", ") k " => " v)))) ==> "two => 2, forty-two => 42"
19:09:49
Bike
emaczen: though i guess this might not be the right sockaddr_in definition for your system
19:15:09
emaczen
Bike: One second, I just googled a bunch of types, made some changes and am testing
19:22:18
pjb
emaczen: for now, the pre-processor is implemented, it should be usable to get the #defines.
19:23:46
pjb
for typedefs, you'll have to wait implementation of the compiler. Or use something like swig/cffi, but it is very deficient.
19:24:38
emaczen
This is really helping me with CFFI, once I get this to work I may give objc OpenStep a crack
19:26:06
emaczen
At least I can deal with C this way... recompiling just to see a different errno and writing so much code just to do that!
19:33:23
pjb
emaczen: CFFI is ok, it's the various ways to parse C headers and generate CFFI code that are wrong.
19:34:12
pjb
Mostly, because they can't deal with all the specificities of C headers. Eg. #pragma pack are ignored.
19:39:07
emaczen
struct sockaddr_in { __uint8_t sin_len; sa_family_t sin_family; in_port_t sin_port; struct in_addr sin_addr; char sin_zero[8];};
19:45:22
emaczen
_death: yes, I know that works it returns 2 which is what AF_INET is #defined to be
19:52:19
_death
it's possible that the layout you describe doesn't match your system's layout.. grovel may be useful here. some quick checks you may try: comparing the struct sizes, offsets for each slot, or simply printing out filled instances that are supposed to be equivalent in both languages
19:54:26
emaczen
_death: Once I get this to work, I'll try it because I do want this to work on different Linux machines too
19:55:32
_death
or come up with a simpler interface and implement it in C.. unless you're actually going for sockets, and then - why not use the one defined by your implementation?