freenode/#lisp - IRC Chatlog
Search
5:39:46
loke
emaczen: yes. But then you have to make sure you free the memory properly later. Sometimes you can use TRIVIAL-GARBAGE to create a weak pointer so that you can free as paert of garbage collection. It depends a bit on circumstances.
5:42:56
loke
There is a plist representation of a struct value, but that's only used when you pass around literal structures. It's actually quite rare, and most C API's work with pointers to structs.
5:43:00
emaczen
loke: I forget that things inside main are just like any other function and would be dynamic
5:43:57
loke
If you want to see an example of a lot of complex struct processing which also includes heavy use of literal structs, you can take a look at my cl-rabbit project.
5:45:58
loke
In that function, RESULT is a literal struct (plist representation) as returned by a CFFI function that returns a literal struct.
5:46:47
loke
You really need to understand what is going on on a low level, or you'll get mighty confused.
5:48:34
loke
struct foo { ... }; Foo someFunc(Foo x); ← Takes a literal struct as argument and returns another literal struct
8:18:13
beach
I think I have a working CST-to-AST system, modulo silly mistakes of course. Now I am thinking of a system for computing indentation from a CST. Such a system would be structured in much the same way as a CST-to-AST system, i.e., it would determine whether a CST represents an atom, a function call, a special form, or a macro call. Function calls are simple.
8:18:15
beach
Special forms are fairly simple, because they have fixed indentation rules. For a macro call, the macro lambda list determines the indentation of the argument expressions, but then, whether an argument expression is a form or something else, can only be determined by expanding the macro.
8:19:09
phoe_
Are you going to expand the macros each single time then? What if they have side effects?
8:19:33
Shinmera
It's also often desirable to be able to give further hints as to how a macro should be indented as the lambda-list by its own does not provide sufficient information about that.
8:20:11
phoe_
But then again, some macros like OPTIMA's and CL-PPCRE's expanders can be really freaky.
8:20:30
beach
I think the Common Lisp HyperSpec has some paragraph about how it is not known how many times a macro can be expanded.
8:21:57
otwieracz
beach: To be honets, my feeeling is that the editor will be broken if it wont work with something allowed in the language.
8:22:02
pjb
As long as you expect your macro side effects to be obtained at "random" times and multiple times…
8:23:21
beach
otwieracz: There is a difference between what the language "allows" and what it defines the effect of.
8:25:05
pjb
one guarantee by 3.2.2.2 is All macro and symbol macro calls appearing in the source code being compiled are expanded at compile time in such a way that they will not be expanded again at run time. It doesn't mention edit-time…
8:34:23
beach
Shinmera: Definitely very useful. If I use a structure similar to that of CST-to-AST, it will be trivially possible to customize the indentation of macro forms.
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