pablo_escoberg has quit [Ping timeout: 246 seconds]
hrberg has joined #picolisp
msavoritias has joined #picolisp
<abu[7]>
Now heading for the train back
<abu[7]>
Your last past has two problems
<abu[7]>
1. (conc Args '(Opts)) is descructive, so it modifies the caller
<abu[7]>
2. (list ... Prg) will not work: http://pb1n.de/?b7aa30 : ((foo 1) (bar 2)) will crash
<abu[7]>
My proposal was 'cons' instead of 'list'
<abu[7]>
Ceterum censeo, I still do not understand what this should be useful for
seninha has joined #picolisp
seninha has quit [Quit: Leaving]
msavoritias has quit [Remote host closed the connection]
pablo_escoberg has joined #picolisp
<pablo_escoberg>
GM/E. Hope you had a great time, and congratulations again. Yes, I had already played with this some more and run into some quote -- Protect errors (which leads me to another question: any detailed listing of error messages and their meaning?). I also realized that conc might be a bad idea there, but figured everything gets restored after
<pablo_escoberg>
the function call. Is that not the case? (sorry for so many questions at once)
<abu[7]>
Yes, thanks, we had a very good time :)
<abu[7]>
A 'prg' is a list of expressions, so 'cons'ing the for loop in front preserves that structure
<pablo_escoberg>
ah, ok, I'll ditch the cons then. It was kind of bugging me anyway. Maybe that will fix it.
<abu[7]>
I'm afraid there is no detailed listing of error messages
<abu[7]>
All symbols between NIL and T are protected
<abu[7]>
See 'symTab' in @src/glob.l
<abu[7]>
or (vi 'llvm~symTab)
<abu[7]>
oops, no
<abu[7]>
(vi 'llvm~$Nil)
<pablo_escoberg>
Oh, yes, that makes sense.
<pablo_escoberg>
As for what it will do, hopefully this will explain fully so there is less confusion: It's a function factory. I want all the objects in this project to take Opts ( a kv pair) as their last parameter and intern those parameters before doing anything else. And I don't want to write the same thing every time, hence the factory.
<abu[7]>
ok
<pablo_escoberg>
Whew! I was worried I was building something useless.
<abu[7]>
The normal way to generate functions in Pil is via 'curry'
<pablo_escoberg>
Yes, and I started out that way. Guess I will now go back to it, but without the fill stuff.
<abu[7]>
And 'new' takes key/value pairs to init new symbols
<pablo_escoberg>
actually, I was using '"make"
<pablo_escoberg>
Wait, it already does this???
<abu[7]>
(new '(+Cls) 'a 1 'b "abc" 'x (1 2 3))
<abu[7]>
such things
<abu[7]>
same for +Entity objects
<pablo_escoberg>
Well, that saved me some time :D. Guess I should have read the docs more carefully. It's a great thing to have there.
<abu[7]>
:)
<abu[7]>
The above sets the values only if +Cls or its sperclasses have no T method
<abu[7]>
Otherwise the T method must take care of it
<pablo_escoberg>
oh, crap! back to the drawing board :)
<pablo_escoberg>
I'll need this in subclasses too...
<abu[7]>
You can do this with (dm T @ (while (next) (put this @ (next)]
<pablo_escoberg>
OK, but I don't want that polluting all my constructor definitions
<abu[7]>
Not all, only the top level super class
<pablo_escoberg>
Right, that will still end up being a lot of places, and that kind of thing really chaffs me (I know many ppl disagree, but it's how I'm wired)
<pablo_escoberg>
so I'm going to make this thing work
<abu[7]>
I would not generalize it, because you do things in the T methods with the arguments anyway
<abu[7]>
Building a list of k/v pairs is tedious and a lot of consing overhead
<abu[7]>
In the T method you don't need the key
<pablo_escoberg>
Of course, but the last argument will always be the same and the processing will always be the same. If there are exceptions for any reason, I just define them the regular way.
<abu[7]>
it is implicit from the value arg position
<abu[7]>
If the processing is the same, you call (super ...) to the parent classes
<abu[7]>
and this can be one single common superclass
<abu[7]>
So I really don't think such a k/v list mechanism is useful
<pablo_escoberg>
sure, I could create a parent class for all my classes that does this. That might be the most straightforward way. Thing is, there will be intermediate classes, and I may not want to call super on all of them.
<abu[7]>
At least I can't imagine a use case ;)
<abu[7]>
I think better wait until you really need it
<abu[7]>
Sounds like premature abstraction to me
<abu[7]>
I believe I can tell you a more elegant solution for any use case
<abu[7]>
In any case, experimenting with such ideas is always good
<abu[7]>
So please go ahead!
<pablo_escoberg>
I get accused of that all the time. I have never regretted any decisions where that accusation has been leveled. It's usually made by people who work on large teams, and I may well be the only person who ever sees this code, so those considerations aren't as germaine here. I abstract the second time I do something, and I was about to do
<pablo_escoberg>
something a second time :D
<pablo_escoberg>
Yes, thank you!
<pablo_escoberg>
I'm going to try the curry thing now and let you know how it goes. Maybe when I finish, you'll change your mind.
<abu[7]>
curry is a bit tricky, please ask for details
<abu[7]>
Also, the name "curry" is historical and a bit wrong, because "currying" is something less general than pil's 'curry' function
<pablo_escoberg>
there is a good article on the blog, but I will definitely ask if I run into a wall (doing my best to respect your time).
<abu[7]>
good
<pablo_escoberg>
yeah, I got that from the docs
<abu[7]>
No worry about the time, I'm back from Berlin now
<pablo_escoberg>
it's more versatile than straight up currying. Currying on steroids :D
<abu[7]>
Yep :)
<pablo_escoberg>
Well, yeah, you're back from berlin, but presumable you have some kind of life and I don't want to monopolize your time. I will ask when I run into a wall, not when I hit a snag.
<abu[7]>
kind of downward-compatible
<abu[7]>
ok, thanks
msavoritias has joined #picolisp
pablo_escoberg has quit [Ping timeout: 246 seconds]
pablo_escoberg has joined #picolisp
<pablo_escoberg>
This time I really think I got it: http://pb1n.de/?22d607 . No currying, just make, but I had to make each individual list. Now to test it...
<pablo_escoberg>
But, quote- -- protected, so not quite :(
<pablo_escoberg>
And I've hit a wall. I don't really understand what quote -- protected is trying to tell me. It it like I'm trying to assign to (quote) ?
<abu[7]>
It is a bit too complicated
<abu[7]>
nesting makes and links etc
<pablo_escoberg>
Seemed like the only way to get everything properly quoted. I played around a lot.
<abu[7]>
I think nothing needs to be quoted
<pablo_escoberg>
but then it will evaluate immediately, no?
<abu[7]>
'append' gives the same return value, but opposed to 'conc' it is non-destructive, building a partially new list insted of modifying the original list
<pablo_escoberg>
The first line in the (if +Dbg) list yields the error.
<abu[7]>
No, I mean a oncrete example of a single call to 'opts_lamb'
<abu[7]>
exact
<abu[7]>
arguments
<abu[7]>
and what the exact return value should be
<abu[7]>
btw, your (dm T is wrong
<abu[7]>
a method takes a parameter list like a function
<abu[7]>
So your first param is the symbol 'opts_lamb' which is then bound
<abu[7]>
Unpredictable results ;)
<pablo_escoberg>
ah, ok, so I need a separate generator for lambdas and methods. I guess that is the issue.
<pablo_escoberg>
Ooh, although looks like I can't do that because I can only return one value.
<abu[7]>
first of all, write syntactically correct definitions
<pablo_escoberg>
syntactically correct?
<abu[7]>
As I said above
<pablo_escoberg>
you mean the method definitions?
<abu[7]>
(dm T (opts_lamb '(Proc) ...
<abu[7]>
so 'opts_lamb' is the first *Argument' to the T method
<pablo_escoberg>
Yeah, that's wrong. If it takes two args, I really can't do what I'm trying to do
<pablo_escoberg>
right, and I thought sending it a lambda would do the trick
<abu[7]>
And a concrete example for 'opts_lamb'!
<abu[7]>
What exactly you want to do
<pablo_escoberg>
That's in the pastebin above. Here it is again.
<pablo_escoberg>
Oh, wait, you already referenced it.
<pablo_escoberg>
I'm using it to create a lambda, which I'm trying to pass to dm, which apparently can't accept it.
<abu[7]>
But I mean an example for a call of 'opts_lamb'!
<abu[7]>
Not all that example
<abu[7]>
What is the RESULT?
<abu[7]>
the INTENDED result
<abu[7]>
Then we can define 'opts_lamb', not the other way round
<pablo_escoberg>
the intended result is that I get a method with the same parameter profile and opts handling as the lambda we are currently producing.
<abu[7]>
like my example (opts_lamb '(A B C) '((foo) (bar))))
<pablo_escoberg>
So instead of writing (dm Foo> '(a b c opts) ((process opts) (do stuff))
<abu[7]>
yes
<pablo_escoberg>
I can just leave out the "opts" and the (process opts) list.
<abu[7]>
my example gives ((A B C Opts) (for X Opts (put This (car X) (cdr x))) (foo) (bar))
<abu[7]>
Is that what you intend?
<pablo_escoberg>
Yes, but dm won't accept that
<pablo_escoberg>
yes, the lambda is the lambda I want now.
<pablo_escoberg>
It's just that dm won't accept a lambda
<abu[7]>
because 'dm' does not work that way
<pablo_escoberg>
exactly! I thought it did.
<abu[7]>
(dm sym . fun|cls2)
<abu[7]>
'fun' is not evaluated
<pablo_escoberg>
So I really can't do what I'm trying to do for dm. Works fine for regular functions
<abu[7]>
no, 'de' is the same
<abu[7]>
the body is not evaluated
<abu[7]>
You can use 'def'
<pablo_escoberg>
right, but it accepts a lambda as an arg
<pablo_escoberg>
I've been using setq, but I assume de does the same...
<abu[7]>
A method cannot be defined with setq or def
<abu[7]>
It must be put into the assoc list in the value of the class or object
<pablo_escoberg>
right. hence the issue. I didn't realize how different dm was from de
<abu[7]>
or you modify destructively after getting the method with 'method'
<pablo_escoberg>
Nah! Way too ugly. Looks like I will really have to go the object route while working with objects.
<abu[7]>
If you can do it at read-time, a read-macro will do
<abu[7]>
(dm foo> `(opt_...
<abu[7]>
That's perhaps the closest
<pablo_escoberg>
yeah, I thought of that, but I need to actually iterate over the kv pairs
<abu[7]>
You can do anything in a read macro
<pablo_escoberg>
Hmmm.... I'll have to look into it more deeply.
<abu[7]>
I make an example
<pablo_escoberg>
thanks!
<abu[7]>
I will also make
<abu[7]>
oops
<abu[7]>
I will also make Prg non-evaluated. That's more usable
<pablo_escoberg>
OK, I've put all the relavant code in one paste http://pb1n.de/?14172c . If you run pil with it, you'll get a quote -- protected.
<pablo_escoberg>
sorry I changed the names...
<abu[7]>
~(opts_meth '(Proc)
<abu[7]>
The quote is wrong
<abu[7]>
Fun is not evaluated
<abu[7]>
so the arg list has the symbol 'quote'
<abu[7]>
Also, better replace "(setq x" with "(setq X"
<abu[7]>
the whole setq is wrong
<abu[7]>
no, not wrong
<abu[7]>
(new '(+Pipe) "./start_sqlite.sh" '((...
<abu[7]>
So "./start_sqlite.sh" is Proc
<abu[7]>
ok
<pablo_escoberg>
I will fix all the namespace stuff once I understand the code. Right now I'm just formatting for my ability to read and edit, later I'll make sure everything is properly capitalized.
<pablo_escoberg>
And yes, that is what proc is, it's the same pipe thing I was working on before
<abu[7]>
yeah
<abu[7]>
good
<pablo_escoberg>
So my code looks a lot like your code, only yours works :D
<pablo_escoberg>
yeah, ok, I'll start making myself hit shift now :D
<abu[7]>
ok
<pablo_escoberg>
Same thing, no? Still get msg_postfix set to itself.
<pablo_escoberg>
hence the can't exec
<abu[7]>
nono
<abu[7]>
I have "msg_postfix" ";^J.read ./in^J" now
<abu[7]>
the exec error is because I don't have sqlite on my phone
<pablo_escoberg>
then I'm looking at the wrong paste...
<abu[7]>
The error was an 'x' instead of 'X'
<pablo_escoberg>
or no, maybe not
<abu[7]>
I did not update the bottom part after the NIL
<pablo_escoberg>
ah, ok, let me give it a shot, and see if I can figure out what you changed.
<abu[7]>
only (cdr X) in line 4
<pablo_escoberg>
hmmm... still not sure what you changed, but I copied and pasted opts_meth from the paste, and still get the same quote -- protected error.
<pablo_escoberg>
Also, wanted to read more about reader macros, and there are no entries in the docs for them, just the section in the reference, which has no examples for the comma macro (totally don't understand what that does).
<abu[7]>
It is not opts_meth (except for the 'x'), it is how you call it
<pablo_escoberg>
right, I'm using the ~ macro
<abu[7]>
that's ok
<pablo_escoberg>
so whence the quote -- protected error?
<pablo_escoberg>
VERY odd behavior here. I wasn't sure if it worked, so I put the commented lines in to make sure it actually worked, and added the constant declarations as well. Now, for some reason, I get this:
<pablo_escoberg>
$177246431236400 (+Pipe)
<pablo_escoberg>
"msg_postfix" ";^J.read ./in^J"
<pablo_escoberg>
: Error: cannot open "./in"
<pablo_escoberg>
Which means it's creating the fist fifo but not the second! How can that even be??
<abu[7]>
*TO_PROC and *FROM_PROC ?
<pablo_escoberg>
yes
<abu[7]>
What does ";\n.read ./in\n" mean?
<pablo_escoberg>
that is a postfix that forces sqlite to read input from the file "in" which is a fifo
<pablo_escoberg>
And what I am trying to do is get rid of all these constants and replace them with options, without having to repeat myself. It's a pattern I will be using a lot
<abu[7]>
good
<abu[7]>
Concerning the mkfifo, you can (trace 'call)
<pablo_escoberg>
Aweoms! You finally get the use case.
<abu[7]>
try to debug it
<abu[7]>
or a breakpoint perhaps
<pablo_escoberg>
yup, will do. one sec
<abu[7]>
(! call 'mkfifo ...
<pablo_escoberg>
Somehow, the quote on the following line got left out and the thing was just deleting the fifos after creating them :). I think this actually works now. Need to play a bit to make sure.
<abu[7]>
great
<abu[7]>
yes, my fault. I did not notice the missing quote
<abu[7]>
btw, there is 'finish' now
<abu[7]>
you call (finish (call 'rm *TO_PROC *FROM_PROC))
<abu[7]>
no need to quote
<pablo_escoberg>
OK, your version now works with the added quote. I just need to find out how it differs from what I have in the project files.
<pablo_escoberg>
Was I right about you now getting why this is useful?
<abu[7]>
No, I still do think it is not useful
<abu[7]>
i.e. I see no use case
<abu[7]>
But as I said, use (finish ...
<pablo_escoberg>
ok, cool. thanks again.
<abu[7]>
it is shorter and uses a 'prg', so no quote needed
<pablo_escoberg>
right.
<abu[7]>
Also more readable
<abu[7]>
I got tired clobbering the code with (push '*Bye
<pablo_escoberg>
great, thanks. That is indeed a lot more readable and less dangerous. code changed.
<abu[7]>
especially in PilBox it is needed quibne often
<abu[7]>
*quite
msavoritias has quit [Remote host closed the connection]
pablo_escoberg has quit [Ping timeout: 246 seconds]