freenode/#lisp - IRC Chatlog
Search
20:12:00
asdf_asdf_asdf
Hi. How get signature callback (function) in SBCL (Common Lisp)? I try: (* func), not working. I defined callback, it: (define-alien-callback ...).
20:14:54
gaze___
maybe a bit of a contentious question, but is there a way to strip symbol names from SBCL when doing save and die?
20:15:19
gaze___
I know it's impossible to fully stop reverse engineering, but it'd be nice to slow it down a bit.
20:15:46
gaze___
and if not with SBCL, is it possible with CCL, CMUCL, one of the more major implementations
20:18:47
asdf_asdf_asdf
gaze___, looks for it: https://koji-kojiro.github.io/sb-docs/build/html/index.html
20:20:32
Bike
https://bugs.launchpad.net/sbcl/+bug/310108 i think stripping an sbcl binary will be problematic.
20:21:58
asdf_asdf_asdf
(define-alien-type nil (struct WNDCLASS (lpfnWndProc 'WindowProc))) How pass signature function to type struct?
20:22:30
Bike
asdf_asdf_asdf: can you just use cffi, as several people have now suggested? it's more common and documented.
20:22:33
anamorphic
gaze___: maybe you can define your own perverted defun and friends to hash the friendy names
20:24:29
gaze___
I'm not entirely sure why the names have to be retained to begin with... isn't SBCL ultimately a compiler?
20:25:08
gaze___
well okay... I guess that functionality is retained so you have to go out of your way to break it.
20:25:08
whartung
…in an ostensibly interactive environment. where meta data and debug information is always valuable.
20:27:41
Bike
sbcl is public domain so you can do whatever with it, but it's common to share sources (e.g., quicklisp)
20:28:33
gaze___
ah well, employers don't always want the details of the architecture of their hardware being broadcast to the world... so if I'm developing a compiler or something
20:28:37
whartung
it would not surprise me if Franz or Harlquins lisp had more aggressive stripping utilities.
20:29:06
Bike
i'm not judging you, i'm just saying what you're doing is not how sbcl is usually used, so it's unlikely to be supported particularly, you know?
20:29:52
Bike
they do stuff like avoid distributing the compiler for the sake of their own IP, stripping doesn't seem far off from that
20:31:33
whartung
just check the pacakge of the symbol so you don’t mung CLUSER etc. That would probably be Bad.
20:32:51
grewal
Change your application design/business model so they never have the executable on a computer they own
20:34:04
whartung
Mind I’m a terrible person to talk to about this, as I don’t grok the fear management is feeling.
20:34:24
gaze___
I mean if even to keep customers from going "ooh there's a lisp interpreter in here" and introducing bugs and complaining to support
20:35:04
gaze___
I don't so much mind people having a whack at reverse engineering... it's always, always possible. A bit of friction might be good tho.
20:36:01
Bike
well, like i said, distributed lispworks programs don't have an interpreter or compiler or anything available.
20:37:50
gaze___
trying to figure out how to strip this information might not be a bad way to learn a bit about SBCL's internals... which, ya know hey, if you wanna master a language, master the compiler.
20:39:31
Bike
also, a tree shaker is kind of different, no? if anything, having a bunch of useless things in the image would make it harder to figure out.
20:39:40
whartung
I honestly off the top of my head don’t know how to lookup a symbol given the text of it.
20:41:39
Bike
eliminating certain things might be problematic. for example, sbcl uses jit compiles for make-instance, so if you're not careful removing the compiler could wreck CLOS.
20:50:39
gaze___
seems like what I wanna do is somehow deep inside sbcl/src/code/target-package.lisp
20:59:25
anamorphic
gaze___: what industry are you in where your binary needs to be scrubbed like this? (curious, if you don't mind)
21:07:58
gaze___
yeah ok, there's someone called nuke-symbol in there that could probably be used as a reference
21:10:24
whartung
symbols are, at a base level, made of two components: the package and the symbol text.
21:14:59
anamorphic
gaze___: I long time ago juho snellman (I think) posted a snippet on github gist somewhere that did a pretty good tree shake. I don't recall what it did with symbols though and I'm having trouble finding it
21:17:09
anamorphic
Huh 17 days ago though... I think there was an earlier attemp that was quite comprehensive too
21:41:41
aeth
anamorphic: Yes, that might work. I think if you operated under the assumption that in e.g. a loop it's probably going to be the same method call(s) for the same generic function, you'd probably be right more than wrong.
21:42:26
aeth
Like if you had a list-or-vector generic, it's probably going to be dispatching on the same class repeatedly.
21:43:18
aeth
But you could do proper JIT, too, which I guess would be something like inlining the probable generic function.
21:52:43
aeth
Actually, I'm curious exactly how make-instance is JITed in SBCL. I always thought CL performance kind of fits in this strange world where AOT-everything-but-CLOS makes sense, but I didn't expect an implementation to actually do it.
21:56:02
Bike
Jitting generic function calls is what beach's clos implementation strategy does. Works well in clasp
21:57:11
Bike
Sbcl jits make instance by replacing obvious calls with calls to a cached function. Since the function can know the class and initargs in advance, it skips a lot of work.
21:59:08
aeth
Is it better for performance to use initargs than your own custom keywords in an initialize-instance defmethod, then?
22:02:07
aeth
It seems fairly common to add keywords to a make-instance with something like (defmethod initialize-instance :after ((object foo) &key
22:04:27
aeth
Bike: Well, I guess I mean that some (not all) of them probably could be rewritten to have extra initargs instead of adding keys, and use those new slots with those new initargs to set the derived values of the other slots, which is what they're probably doing with the keys.
22:18:08
White_Flame
Bike_: by "JIT" do you mean the actual call site is recompiled eliminating the function call, or the callee is recompiled and dispatched through an indirecting pointer?
22:26:57
White_Flame
Bike: yeah, actual call site recompilation would be the only way to fully optimize local numeric types and inline small methods. I wonder how big of a change that would be for existing implementations, if it'd basically require a new one
22:27:04
Bike
it transforms (make-instance 'name ...initargs) into (funcall (load-time-value (ensure-ctor ...) t))
0:29:04
asdf_asdf_asdf
Hi. Which instruction in Lisp do "function pointer" - https://en.wikipedia.org/wiki/Function_pointer? E.g.: "double (*func1)(double) = cm_to_inches;" - How it do?
0:46:14
aeth
asdf_asdf_asdf: This sort of wrapping is seen as boring and is almost always automated in some way, e.g. XML/JSON spec parsing, grovel, cl-autowrap, claw, etc.
0:46:46
aeth
It's possible that the only person who knows the answer is the author of such a tool, and that author will probably say "use my tool"
0:46:48
no-defun-allowed
Um, maybe they mean they want a "pointer" to a function. How about #'foo for the function FOO?
0:47:17
aeth
no-defun-allowed: no, asdf_asdf_asdf has been for days/weeks asking in here how to manually wrap WinAPI in a SBCL-specific way
0:48:19
aeth
which is probably pretty close to asking how to manually compile by hand LLVM IR to x86-64 asm in #llvm
0:55:39
aeth
asdf_asdf_asdf: If I were you I would just take the offer from borodust from last week. <borodust> lemme know what header you need a wrapper for and i can arrange it in 15 min or smth
0:56:18
aeth
asdf_asdf_asdf: At the very least, you get to see what correct output looks like even if you don't do the whole thing automatically generated
1:16:28
asdf_asdf_asdf
Thanks, but which function is equivalent to "double (*func1)(double) = cm_to_inches;"?
1:18:09
Bike
none of those things are functions. you are asking a question that doesn't really make sense in context, like how much green weighs
1:19:38
Bike
https://common-lisp.net/project/cffi/manual/html_node/Tutorial.html#Tutorial here, read this. it explains callbacks
1:19:45
aeth
Do you mean function pointers for interfacing with C or are you asking about higher order functions or...?
1:41:01
asdf_asdf_asdf
How pass signature to variable? Signature it for example: LRESULT (int int). I must pass it to variable. How it do?
2:02:59
asdf_asdf_asdf
I have (define-alien-type nil (struct foo (lpfnWndProc ...))) If instead ... will be WindowProc I have error: "Undefined alien ...".
2:09:01
oni-on-ion
https://coliveira.net/software/writing-a-win32-application-in-sbcl-common-lisp/ ?
2:12:09
asdf_asdf_asdf
oni-on-ion; how write it in Common Lisp: double (*func1)(double) = cm_to_inches;"?
2:52:01
pjb
asdf_asdf_asdf: by the way, yesterday I passed by a github providing Windows ABI for CL…
3:00:18
aeth
pjb: Several people have provided several different links for that, and borodust offered to run his autowrapper. asdf_asdf_asdf seems to be ignoring all of that.
4:22:42
Nomenclatura
I've been lazily trying to get into programming for a while... like French.... Sure I have learned some Frech and some programming but I dunno a single person who speaks Frech to practice with and I really dunno what to do with programming.
4:23:35
Nomenclatura
Sure, I can learn how to code a sqare and how to add numbers ordisplay a stupid hello world, but I dunnot what to actually do with that
4:26:34
Nomenclatura
there has never been a single problem I haven't solved with existing software or a wuick bash hack
4:46:21
Nomenclatura
you know, when I was in school and we took those aptitude tests meant to guide you what you should study?
4:46:23
oni-on-ion
the first thought that surfaces in your heart when you ask yourself "what should i make"
4:47:23
oni-on-ion
being overwelmed with option and choice and variety and FOMO is something i am personally very familiar with
4:48:07
Nomenclatura
sure. thought building a website was a good idea but it feels such a waste of time when there is a lot of ggood web frameworks I could just use
4:48:38
oni-on-ion
2wk ago i just buckled down all my tools and gear and mindset and environment and went to work. feels great now. work is hard too dont let the rough spots break you down just climb over them
4:48:51
beach
Nomenclatura: Here is a list of stuff you can work on: http://metamodular.com/Common-Lisp/suggested-projects.html
4:49:29
oni-on-ion
Nomenclatura, hehe yep, i had that mindset as well. there will *always* be something else to tempt us. but the key is to invest in the one thing, that makes all the difference; to put your time and sweat and effort and attention toward something is what makes it worth it. (took me a while to learn this)
4:49:51
gabbiel
pjb: That save-place macro is good, but I was thinking, what if I want new to be nil?
4:50:38
White_Flame
Nomenclatura: there are 2 ways of programming; Programming as a hobby, and programming to get something done
4:51:06
White_Flame
programming as a hobby works because people intrinsically enjoy the act of programming, and the nested challenges it offers
4:51:29
White_Flame
but, if you don't really get any pleasure from programming for its own sake, then that's different
4:53:18
White_Flame
it won't teach you actual pragmatics of programming, but is the magic paper into many programming jobs
4:55:26
White_Flame
but if you want to transition into programming specifically (not sure where the label "IT" has hits borderlines), that is a path
4:57:10
Nomenclatura
I appreciate programming, it's beautiful... so is Music and I am not trying to become Perlman
5:01:11
White_Flame
as everybody gets more and more greedy, and interactions become less about value exchange and more about lock-in and obligatory monetary extraction, I like money less and less
5:01:32
Nomenclatura
oni-on-ion: Right.But more because when you get paid for it they start to ask for a lot of other stuff such as admin paperwork, filling spreadsheets, studying boring ISOs and stuff
5:01:59
edgar-rft
oni-on-ion: try getting paid for something you don't like from the beginning to avoid disappointment
5:15:05
oni-on-ion
Nomenclatura, yes. i have really nothing else that is as interesting for a hobby ("spare time") as programming. so if i were programming as a job, i would probably play video games and watch movies instead =/
5:16:16
oni-on-ion
LdBeth, i don't know... but i would not feel good to get paid *and* enjoy something
5:16:38
LdBeth
Probably gettin paid for streaming video games but write programs instead would be more fun XD
5:19:59
oni-on-ion
play points, work points. work a bunch, build up play points. play a lot, build up play points. need work points to work, need play points to play. now here is the trick to it. when you play too much and run out of play points, it becomes work. people start to get mad at their video game or headaches and social problems etc. now the same with too much work; it becomes play and does not get serious. need a delicate balance of both
5:21:18
oni-on-ion
excersize and cleaning and difficult things like waiting in line counds as "work" (contribute to society in some form)
5:22:48
oni-on-ion
programming as it is right now, there are things i dont want to do (work) and things i want to do (play). it is a real-time balance adjustment. can't always do the fun stuff because then it turns to work (ie. defensive optimization, overdesign and adding problems just to solve them)
5:24:02
oni-on-ion
(spending too much working, then i will start to configure emacs and change font colors and try to force more caffeine and frown more etc)
5:25:09
oni-on-ion
sorry for the non-CL speak. just realised i was spending 30min on reddit and feels like it turns into a chore. the laughs are over. back to work ! =)
6:56:18
shangul
Any OS with Lisp tools and a Lisp implementation as its shell? Emulating Lisp machines for example
6:58:27
beach
shangul: There is also Movitz, but I don't think it is being maintained. The author has declared that he wants to create a new version.
7:00:28
beach
shangul: I am planning on as well, but it is not going to be imminent: http://metamodular.com/closos.pdf
7:14:19
beach
Though if you read Tanenbaum & Bos "Modern Operating Systems", you will learn that Genera, Movitz, and Mezzano can't possibly exist, because according to that book, it is impossible to write an operating system in a language that requires automatic memory management.
7:17:48
beach
shangul: It does not have to contain any assembler. There can be a code-generator module in the compiler that generates machine code directly, without using an assembler.
7:18:30
no-defun-allowed
Alternatively, you could generate consing-free code for your CL runtime. The T Scheme system did this a fair bit for its own runtime.
7:20:56
edgar-rft
Build your own Lisp Machine: http://www.justgeek.de/a-fistfull-of-transistors-building-a-cpu-from-scratch-1/
7:21:25
beach
shangul: Most Common Lisp compilers would have an intermediate representation that looks like a symbolic version of machine code. You may or may not call that "assembler".
7:21:43
beach
shangul: Certainly, the compiler needs to contain knowledge about the processor instructions and such.
7:22:14
no-defun-allowed
I should also add most C operating systems are written in invalid C technically: how do we get pointers to wherever (such as 0xb8000 for video memory) and what do we do without malloc, free, etc? There is no conforming C runtime or client code there.
7:22:46
beach
no-defun-allowed: That's what I meant when I said that no operating system can be written in C.
7:23:45
no-defun-allowed
Yes, but it's more of a comment on ridiculous constraints set by the authors.
7:24:17
beach
The standards (C and Common Lisp) do not have anything in them that allows direct access to memory by conforming code.
7:26:25
MichaelRaskin
Bash is better than C. You have a chance to concatenates trings in bash and not leakmemory
7:28:04
jackdaniel
it is like in this meme: 'CL: "I feel sorry for you C!", C: "I don't think about you at all CL"'
7:28:11
oni-on-ion
C is unix language -- dumping core is like stacktrace for a process. don't see how its like ebola
7:28:39
MichaelRaskin
It's fine when it does dump core, the problem is that it should have but does not
7:29:03
jackdaniel
I know that I may have incited bash (sorry about that), but let's focus on the channel topic :)