Re: PicoLisp is DEAD (Was: PicoLisp and its (lack of) libraries)
Alexander Burger schrieb: OK, I understand. The language is not useful or usable, and the Community (I count 70 members in this list) is silent. Oh oh ... Alex, your conclusion is not necessary true. If most are silent that has not to mean, they conclude with Henrik. At least me, if I do not like something, or I am feeling it is dead, I will unsubscribe. The lack of libraries may be a problem from time to time, but PicoLisp has also to offer a lot, like its DB with Pilog, its Web-Framework, its simplicity. Often people need a language that allow for quick and dirty development. So lacking a library could be a show-stopper for them, as they are not willing to spend time to develop what they need. They want to throw together basic components to build a new app they can use. Perhaps for them, PicoLisp is not an alternative. But if you want to develop a coherent, portable app, with storage backed up by a DB with an elegant query language (Pilog) that does not need much resources -- PicoLisp may count in! I am interested in PicoLisp as you know. I've tried to use it for my in-house project. Unfortunately I couldn't not, not cause by lacking any library, but as my co-workers do not know Lisp and are very reluctant to learn yet another language beside C++, Java and Ruby used for most of our tools. So this may be another reason -- PicoLisp is a Lisp. You know, that language with a lot of silly parentheses ... ;-) Anyway, happy new year and please keep up with your nice language. It is not mainstream, but it has its place!!! Ciao, chi. -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: How much evaluation takes place?
Alexander Burger wrote: Hi Cle, Hi Alex, (setq *Signals NIL) (de _storeElement (@Queue) (curry (@Queue) (Attributes . SubExprs) (queue '@Queue Attributes) NIL ) ) (setq strml:Signal (_storeElement *Signals)) ^ Here lies the problem. As value of the transient symbol *Signals is NIL (from the 'setq'), '@Queue' is NIL when 'curry' runs. A ... (...) : (setq strml:Signal2 (_storeElement *Signals)) Here you are in another 'load' environment, so *Signals is a new, different symbol. That symbol's value is not set to NIL, so it is still pointing to itself (auto-quoting of transient symbols). uh ... The solution is simple: Just always quote the argument: (setq strml:Signal (_storeElement '*Signals)) Autsch! Gnark! Thank you very much. Although thinking a lot, this one was a miracle for me. But now, it is clear for me. Doh! I wish you a Merry Christmas :-) Cheers, - Alex Ciao, cle. -- UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe
Re: Pilog: predicate to determine free or bound Pilog variables?
Alexander Burger wrote: Hi Cle, Hi Alex, (...) The most languages try the hell to avoid such ugly things like a SIGSEGV or SIGBUS ;-) PicoLisp doesn't want to do that. After all, these are error messages, resulting from hardware runtime tests, optimal in terms of efficiency and reliability. A language cannot check for every possible error situation anyway (think of the halting problem). This is ok, I think! Only it would be nice, if the reference manual would describe more clearly what is going on and what is dangerous. But perhaps with time I get more used to picoLisp, I can help a bit with the documentation. And PicoLisp can't do that without losing flexibility or efficiency. In this regard it behaves like C. You can easily crash PicoLisp, for example, by jumping to an arbitrary memory location (function pointer). I think this is acceptable, and not a problem in practical work. Not meant as critique, but jumping to a non-sense function pointer thereby killing the picoLisp process has another quality for me, than calling 'unify' for instance outside a Pilog clause and get a SEGFAULT for that blasphemy. The latter could be detected by the interpreter, IMO. But this does not mean, I write a ticket against this feature. I will learn to cope with it :-))) Instead, PicoLisp encourages a defensive interactive development style, with tracing, debugging and introspection tools. So does Erlang, Smalltalk, Ruby and a lot of other languages as well IMO! So perhaps you would state, that picoLisp require a defensive style? ;-) But the above version ('make' or 'solve') also calls Lisp ;-) Yeah! But this is only one place, where Lisp is being used. And the whole Pilog will get the the possibility to search for all solutions of a query without implementing the query in Lisp :-) Ah, I see. I was thinking to implement 'findall' via the 'T' property. This seemed easier, and more efficient, because the requested list is already there without any further processing. Ok, I see! But this was only for explanation purposes of 'findall'. In reality the query to 'findall' could be as well something like: All ways from this certain signal backwards until a end-of-tracknet was reached. Once got those ways, something could be done with them, e.g. check, that there will be a preceding signal on every way announcing that certain signal in question. So it would not only be a query like that I formulated in my ascii example, but a much more complicated one! Ah, this is understandable. I fear I was unclear, though! My question should be, if 'findall' has a chance to get into the official picoLisp implementation (misc/pilog.l would be ok), or whether I have to reside the implementation in my own library? If you collect more such useful predicates, we should think about the name of such a library. I wouldn't use misc/pilog.l, because in misc/ there are simple tests and arbitrary little projects, but no libraries. It should better be some lib/xxx.l for Pilog extensions. Yeah, I think you are right! But what could be the name of such a lib? Until now, we have two such clauses gotten 'retract' and 'findall'. Those would be Prolog compatibility functions. But calling it prolog.l .. :-/ Cheers, - Alex Ciao, cle. -- UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe
Re: Pilog: predicate to determine free or bound Pilog variables?
Alexander Burger wrote: On Wed, Dec 23, 2009 at 11:24:15AM +0100, Henrik Sarvell wrote: extpilog.l maybe? Nice. Would be in sync with other extensions. Why not? This would allow us to put in other useful Pilog clauses as well, whose would not necessarily be Prolog compatibility clauses. Another idea could be auxpilog.l ... But as you mention it where in sync with other extensions, where in the picoLisp sources are other files following that scheme i.e. extwhatever.l. It seems to me, that extpilog.l would be the first one, wouldn't it? Ciao, cle. -- UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe
Re: Pilog: predicate to determine free or bound Pilog variables?
Alexander Burger wrote: Hi Cle, Hi Alex, (...) Yeah! I like this a lot better :-D That prove you again being the guru and me the disciple :-) Not at all! I must say your discovery of using 'fill' here is ingenious. A nice coincidence of Lisp pattern variables versus Pilog variables. thank you for the flowers :-) But I had thought you did the Lisp pattern variables looking like Pilog ones on purpose to just allow that trick :-O I would suggest two changes: 1. '@Var' is not always a variable, but may be any kind of pattern. So let's better call it '@Pat'. Wholeheartly agree! First it was only a variable. But later it was mutating to a pattern. So you are totally right here. Like I did not thought to use 'solve' again after finding a solution, I also did not think for re-check the variable names afterwards :-( 2. (val '@Var) is a tautology. Just @Var (or @Pat) should suffice. With that, we would get (be findall (@Pat @P @Res) (@Res solve (- @P) (or @Pat (fill (- @Pat))) ) ) What do you think? I like this even more! It is already builtin in my application code! :-D Thank you for these improvements :-) Cheers, - Alex Ciao, cle. -- UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe
Re: Pilog: predicate to determine free or bound Pilog variables?
Alexander Burger wrote: Hi Cle, Hi Alex, The usage of 'unify' is interesting, however. I had found it, but did not understand, how to use it from the manual. It seems, it is only usable in Lisp statements of Pilog clauses. Otherwise, I got SIGSEGV regulary :-/ Yeah, it tries to unify variables with the current Pilog environment. Gets angry if it doesn't find any env ;-) hmmm ... then let me make the statement, that picoLisp is also, ahh ..., different from other interpreted languages here. The most languages try the hell to avoid such ugly things like a SIGSEGV or SIGBUS ;-) (...) hmm, you could stick with 'solve' (as you did in a previous version): (be findall (@Var @Pred @Result) (@Result solve (list (- @Pred)) (or (val '@Var) (fill (- @Var))) ) ) Yeah! I like this a lot better :-D That prove you again being the guru and me the disciple :-) I used 'solve' before, but as it didn't fit my needs, I switched to 'goal' and 'prove'. But after found a working version, I did not came back to 'solve' :-( But I learn ... :-) But I have switched the implementation a bit by replacing '(list (- @Pred))' by '(- @Pred)' alone to be consistent with clause 'or' for allowing a whole query instead a clause only. So I can formulate this: (? (findall @C ((ascii @C @N) (different @N 66)) @L)) I like it now :-D rules, I would like to stay away from Lisp statements within Pilog clauses as far as possible. Only if performance really matters or if But the above version ('make' or 'solve') also calls Lisp ;-) Yeah! But this is only one place, where Lisp is being used. And the whole Pilog will get the the possibility to search for all solutions of a query without implementing the query in Lisp :-) (...) Anyway, if we finish our 'findall' would you also consider to put it into the pilog.l to be included into the standard library? I'm not yet convinced if and why 'findall' is useful. If so, yes. Oh, what a pitty! But to be fair, it may be useless, if you are willing to use 'solve' in a Pilog clause. It is useful if you decide to stay in Pilog as far as possible, though :-) Otherwise, I would prefer to keep it separate, like other also possible useful predicates (e.g. 'mapcar' in misc/pilog.l). I dont' want to put too much load on the base system, which is more focused on using Pilog as a database query engine. For dedicated Prolog programs, a dedicated library (could also be included into the standard release) might be more suitable. Ah, this is understandable. I fear I was unclear, though! My question should be, if 'findall' has a chance to get into the official picoLisp implementation (misc/pilog.l would be ok), or whether I have to reside the implementation in my own library? Cheers, - Alex Ciao, cle. -- UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe
Re: Pilog faster than DB access?
Hello Henrik, Henrik Sarvell wrote: I don't know exactly the circumstances of what you're trying to achieve, ok, I will try to answer this in the next mail to Alex ... but if I were you and needed to access by unique id I would first use +Key in the relations: (rel id (+Key +String)) Ah, that makes sense! But it will only work for my id relation ... but I will also access them by 'src' and 'tgt'. Then I would use (db) to access (like you do but without the Pilog): (db 'id '+Test 1) Ok, I will try this too for sure ... thanks! :-) I think that's the fastest way, see also (collect) and (aux) for more utility functions that will let you access the DB without using Pilog. But in the end, I *want* to use Pilog, I explain in the later mail. :-) (...) Thank you for your non-ending effort to answer my noob questions :-) Ciao, cle. -- UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe
Re: Pilog faster than DB access?
Alexander Burger wrote: Hi Cle, Hi Alex, let me first correct some errors: (pool test) This is a funny one. As the value of 'test' is a function definition, you get a rather strange database file ;-) Ahhh ... this was a copy/paste error from the console into the mail. My DB file was named test :-) The name test, on the other hand, will give a conflict as there is a directory with that name. I take x.db for now: Ahhh not for me ... as I am working within another directory parallel to picoLisp ;-) (pool x.db) Ok, I agree :-) (class +Test +Entity) (rel id (+Ref +String)) (rel src (+Ref +String)) (rel tgt (+Ref +String)) (new '(+Test) 'id 1 'src A 'tgt B) (new '(+Test) 'id 11 'src B 'tgt C) (new '(+Test) 'id 111 'src C 'tgt D) If 'new' is called this way, it will not create database objects but memory-resident symbols. You should call either :-O But ... but ... but ... URGHS! :-( I had looked especially into the x.db file and found my keys 1, 11 and 111 there. So I thought .. now I feel stupid again :-( No! I am stupid ... in my real program I used 'new!' and *not* 'new'. So in my real slower program the DB was filled but only by accident :-} (...) This would actually return no result at all, as you pass a _number_ '1' while the key is a _string_. I suppose the double quotes got lost when copy/pasting the expression from the console? Yes you are right! Those missing were not the problem. Only the missing 'T' was a real problem in this made-up example so far! Thanks for pointing this out! (...) Yes, the Pilog queries 'select' and its small brother 'db' are intended to return result _sets_, useful in GUI search components. For simple direct DB accesses Pilog is rather overkill. You typically use the Lisp function 'db' for that: : (db 'id '+Test 1) - {2} The Pilog 'db' is actually a misnomer. It behaves more like the Lisp 'collect' function. Ok, perhaps I could use the Lisp 'db' function when I have a direct access :-) But anyway I will also need the Pilog 'db' clause. But I would need it with a functionality like SQL select ID, SRC, TGT from +Test where ID = 1' an *not* select ID, SRC, TGT from +Test where ID like 1% is there any way to achieve my goal? (...) True. Pilog is a powerful search mechanism, but you have to understand that for a simple indexed access the overhead of setting up the query and communicating environments from Lisp to Pilog and back is much larger than the actual db access. So it is not recommended, and was never intended, to use Pilog to retrieve a single value from the DB. Ok! So perhaps I cannot use the DB for my purposes :-( (...) Perhaps you should try with the corrected version (see above). Also, when using DB _plus_ Pilog, you get the overhead from both worlds. You could also try a DB version without Pilog. Is this possible? I do not know for sure. I originally want to use Java + Prolog for my application. Then I detected your picoLisp ... (...) There are many ways to tune the performance. Perhaps you can elaborate a little more on the details? Ok, here comes my story! Currently there is an application/tool written in C++, which is very hard to maintain. The task is, to read-in some XML formatted description of a rail infrastructure. To let our main application deal with the original rail infrastructure (points, tracks, signals ...) a team has to take the original planning sketches and describe them into XML. There are a lot of rules to obey to describe the infrastructure properly. To help the team with that task, a check tool was written, that read in said XML description and check them according the rules of our projection handbook/guide. My idea now is that I can write a new check tool that will have the rules formulated in Pilog (formerly Prolog). All in all I would think, that the resulting tool will be much more friendlier to maintain as the said C++ one. For that I need to formulate the edges of the tracknet somehow (for instance) as Pilog facts like this: # (Edge id fromNode toNode) (be edge (ts1 end#1 points#1)) (be edge (ts2 points#1 points#2)) (be edge (ts3 points#1 points#2)) (be edge (ts4 points#2 end#2)) Would describe a graph like this (better look with a fixed size font): ts2 ___ ts1 / \ ts4 End#1 |---o Points#1 Points#2 o---| End#2 \___/ ts3 Then I have a Pilog clause like this: (be walk (@Begin @Way) (edge @Begin @From @To) (walk @To (@Begin) @Way) ) (be walk (@Node @Way @Way)) (be walk (@FromNode @AuxWay @Way) (edge @Edge @FromNode @ToNode) (walk @ToNode (@Edge . @AuxWay) @Way) ) Which would allow me to iterate from a certain edge thru all reachable edges until no other way can be found anymore. This clause would form a base of my future
Re: Pilog faster than DB access?
Henrik Sarvell wrote: Sure, Pilog works fine if you have something more complex, but you get quite far with (db), (aux) and (collect). (...) Then you get all objects with D as src, I think you need to come up with something more complex in order to actually get to a reasonable real-world Pilog example. My Pilog program will be complex. As I have written in my last mail to Alex, I will have to traverse directed graphs egde by edge and ensure rules are fulfilled. An easier rule could be formulated like this: Ensure, that for every path thru a train station beginning from every entry signal up to the exit signal, there is no path longer than 500 m without any intervening signal or auxiliary signal :-) This could be nicely solved with Pilog :-))) My tutorial series has a few fairly simple Pilog examples here: http://www.prodevtips.com/2008/04/28/advanced-oodb-in-pico-lisp/ I had already a fly-over over your site, it is really nice done! I will look at it again, though. But I think, I will have no problem with Pilog, but more with the database thingy :-) (...) Ciao, cle. -- UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe
Re: Pilog faster than DB access?
Alexander Burger wrote: Hi Cle, Hi Alex, (...) If 'new' is called this way, it will not create database objects but ... :-O But ... but ... but ... URGHS! :-( I had looked especially into the x.db file and found my keys 1, 11 and 111 there. So I thought Right. I never tried it this way, but the reason is that though there were memory-only objects created, the relation-handling side-effects of '+Ref' etc. were executed, so that the indexes were in the file but not the objects. ahhh ... now I understand, what I've seen :-) (...) The way I would use is the already-discussed 'collect' (...) If you really prefer Pilog also for direct accesses, then you can still call it the direct way: Nice idea! Now I reformulated my Pilog rules for usage with database like this: (be graph:walk (@Begin @Way) (@E db 'id '+DB:Edge (- @Begin)) (@To get (- @E) 'tgt) (graph:walk @To (@Begin) @Way) ) (be graph:walk (@Node @Way @Way)) (be graph:walk (@FromNode @AuxWay @Way) (@Edges collect 'src '+DB:Edge (- @FromNode)) (lst @Edge @Edges) (@Id get (- @Edge) 'id) (@ToNode get (- @Edge) 'tgt) (graph:walk @ToNode (@Id . @AuxWay) @Way) ) This is an excerp from my actual code. You will find, that I use a module: prefix in my clauses to modularize the Pilog clauses and facts. A slight misuse I know, as those prefix should be used for function in shared libraries ... :-} With those changes the traversion becomes a bit faster; it needed 87 seconds for 1000 pathes, where Pilog facts would take 3 seconds ;-) Any other hint? :- I'll study your project now ... Looks interesting :-) Thank you for your interest :-) Cheers, - Alex Ciao, cle. -- UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe
Re: Pilog faster than DB access?
Alexander Burger wrote: Hi Cle, Nice idea! Now I reformulated my Pilog rules for usage with database like this: (be graph:walk (@Begin @Way) (@E db 'id '+DB:Edge (- @Begin)) (@To get (- @E) 'tgt) (graph:walk @To (@Begin) @Way) ) (be graph:walk (@Node @Way @Way)) (be graph:walk (@FromNode @AuxWay @Way) (@Edges collect 'src '+DB:Edge (- @FromNode)) (lst @Edge @Edges) (@Id get (- @Edge) 'id) (@ToNode get (- @Edge) 'tgt) (graph:walk @ToNode (@Id . @AuxWay) @Way) ) Hehe, nice. Our mails crossed-over, without paying attention to a point or signal ;-) Yeah, but also without any accident ;-))) The solutions look pretty similar. That should be so! As they say in China: 英雄所见略同 (Heros have the same mind/opinion) ;-) As you see, the explicit 'get' can be substituted by a more concise 'val' predicate. To rephrase the chinese sentence once more: your solution was exactly the same as I came up with my first attempt. But due to the fact, I use '+String' for all fields, the Pilog 'db' clause did find the wrong solutions. To handle that, I did introduce a 'equal' check then. But now, if I can use '+Number' for the id's the 'equal' check could vanish, I assume. :-) But I would guess -- if I understood your and Henriks explanation correctly -- that my solution should be faster, as I use the Lisp access functions, shouldn't it? I also notice that the '@From' in my walk/2 is not used and thus unnecessary. So I would propose (especially if you use a numeric 'id'): I would think, *only* if I use numeric 'id', 'src' and 'tgt'. Otherwise the 'db' clause of Pilog would find a connection 'pt11' in e.g. the 'src' field although it was requested only to search for a connection from 'src' = 'pt1' ... :-( But I will have a look, if I can use numeric ids for all properties of an edge. I would guess that unification in my Pilog solution should also be faster, if those arguments were numeric instead of strings. :-) And perhaps the DB behaves better then. But if I do this, I will need another facts, to mark, which node ('src' or 'tgt') is a start or end point of a tracknet. At the moment those are named like End#12 or such ... (...) I would not worry about that. It is just the other way round: If the interpreter finds an _undefined_function_ with a colon in the name, then it searches for a library. This doesn't inhibit us, though, to define such functions ourselves. And here we are not dealing with functions anyway. A good to know! So I can go forth with that procedure :-) With those changes the traversion becomes a bit faster; it needed 87 seconds for 1000 pathes, where Pilog facts would take 3 seconds ;-) This large difference is rather strange. I would expect _some_ slowdown, as the DB involves I/O operations while Pilog only runs in memory, but not so much. That was, what made me crazy too ... I had thought, that direct access via an index should be faster than sequential search of 360 edges again and again and again ... So I am really eager to understand, why this is not the case, even with my Lisp database access in Pilog? Otherwise I feel I did something wrong perhaps ... The question is what happens if you have millions of edges. Then the linear lookup in Pilog versus the index accesses in the DB might show effect. If it really need millions of edges to show effect, I can safely reside on my Pilog facts, as my tracknet will never be so large. The 360 edges are a not so small tracknet already :-D Ciao, cle. -- UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe
Re: How to modify class variables?
Alexander Burger wrote: Hi Cle, Hi Alex, back from shopping outside, I read your explanations. Let me thank you. Although I have read the reference manual several times (and have it open while I am coding) I did oversee 'push' and 'queue' totally :-( But I know about 'inc' but for my learning purposes, I did it more complicate on purpose here ... however, thanks anyway you for trying to improve my skills :-) On Thu, Dec 10, 2009 at 08:32:38AM +0100, Alexander Burger wrote: oops, didn't look carefully enough. The 'foos' method must, as in your *1c* case, specify the current '*Class' directly: (dm foos () (mapcar cdr (val (get '`*Class 'Foos))) ) Now I begin to grasp your intention. Hard coding the class into a method is not nice. So wouldn't simply I second your reason, it is not nice, but ... (dm foos () (mapcar cdr (val (: Foos))) ) do what you want? Howevery only if the receiver is the class. If I use an instance as receiver, it would not work! I would like to code the method the way, that the method will work regardless if the receiver is a class or one of its instances; like it works in Smalltalk, C++, Java, Ruby ... So is there a possibility to trick with e.g. 'with' or 'var:' access the value regardsless of the receiver? Thank you for your effort to explain me the mechanisms so far ... :-) Ciao, cle. (...) -- UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe
Re: How to modify class variables?
Alexander Burger wrote: Hi Cle, Hi Alex, (dm foos () (mapcar cdr (val (: Foos))) ) .. Howevery only if the receiver is the class. If I use an instance as receiver, it would not work! I would like to code the method the way, that the method will work regardless if the receiver is a class or one of its instances; like it works in Smalltalk, C++, Java, Ruby ... This is rather straightforward: (dm foos () (mapcar cdr (val (or (: Foos) (var: Foos ) Cool! This is nearly perfect :-) Really nice! Thank you :-))) (...) With this solution we still avoid hard-coding the class into the method, which would give problems, for example, if the 'foos' method were inherited by a subclass. Superb! :-) My real class is now working nicely without hard coding the class' name within a method due to your hints. :-) And I have learned a bit more ... Cheers, - Alex Ciao, cle. -- UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe
How is the documentation written?
Hi Alex, I would like to ask you, in which format the user documentation like Reference Manual or Tutorial were written? In the distribution it is contained as .html but is this also the format it is written in the first place? If I would like to patch (read: propose changes) to the documentation, how would I have to submit them? In which format? Ciao, cle. -- UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe
Re: How to modify class variables?
Alexander Burger wrote: (...) There was one more class variable, 'aux'. I changed that, too. The problem was that both 'dbf' and 'aux' exist also as object attributes, so I had to be very careful when changing some of them to upper case. I checked it in as new testing release. Any feedback (or error notes) welcome! At least it worked under MacOS/X 10.6 (Intel) and 10.5 (PPC). :-) But I would suppose to document this proposal also in the Reference Manual under Naming Conventions. Cheers, - Alex Ciao, cle. -- UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe
Pilog faster than DB access?
Hello, today I tried to verify if using a database instead of Pilog facts would speed up my processing. While trying this, I stumbled over the following. Suppose: (pool test) (class +Test +Entity) (rel id (+Ref +String)) (rel src (+Ref +String)) (rel tgt (+Ref +String)) (new '(+Test) 'id 1 'src A 'tgt B) (new '(+Test) 'id 11 'src B 'tgt C) (new '(+Test) 'id 111 'src C 'tgt D) (commit) (? (db id +Test 1 @E) (show @E)) The last Pilog query will successively return three answers where I thought to get only one. I understand, why 'db' will deliver three results. But the question comes up, how I could formulate the query using only exact matches! Without this, the 'db' query would return similar matches that I have to explicitely guarding against with e.g. 'equal' like this: (? (db id +Test 1 @E) (val @Id @E id) (equal @Id 1) (show @E)) But this would defeat the reason, why I tried to use a DB at all. I hoped that accessing an Edge via an index would be faster than asking Pilog to match against all its facts until it found a corresponding it could unify against. So could this be the reason that my DB solution of traversing all ways thru a graph is a lot slower than using Pilog facts? Both are trying to iterate over the same graph built by 362 edges. Whereas the Pilog facts will allow for finding ca. 1000 ways per 1-2 seconds, the database solution was canceled after some time, as it did not reach the first 1000 solutions before I lost my patience ;-) Or is there any way to improve the performance of the DB? For instance by only matching exactly in the db query for a certain edge? Thanks and Ciao, cle. -- UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe
Re: How to modify class variables?
First let me thank you and Henrik for the insight you gave me. Alexander Burger wrote: And one more thing I just remember: On Wed, Dec 09, 2009 at 01:10:21PM +0100, Alexander Burger wrote: There is no separate 'set'ter function needed, as the 'any' argument in (var sym . any) A 'set'ter function would be pretty useless if there is no value yet, or if the value were set to NIL once, because if there is no value the property cannot be inherited, i.e. the class in the hierarchy that is supposed to receive that value cannot be found :-) So a NIL value _must_ be defined as (var name NIL) to have a cell with NIL in its CAR, but still a non-empty property that can be inherited. Later you can do things like (set (var: name) 123) and the '123' will arrive in the correct class. Stupid me, but I did not recognize that I could use 'set' for those task :-} This would be exactly the behavior I need ... But there seems to be something that slip me. I have wrote some example code, that show the behavior I need. ==8X== (class +Foo) # id (var N 0) (var Foos ()) (dm nextId () (set (var: N) (+ (car (var: N)) 1))) (dm T () (=: id (pack Foo# (nextId This))) (conc (var: Foos) (list (cons (: id) This))) ) # (dm foos () (mapcar '((X) (car X)) (var: Foos)))# *1a* # (dm foos () (mapcar '((X) (car X)) (get '`*Class 'Foos))) # *1b* (dm foos () (mapcar '((X) (cdr X)) (get '`*Class 'Foos))) # *1c* (dm show () (prinl Foo id= (: id))) (show (new '(+Foo))) (show (new '(+Foo))) (show (new '(+Foo))) # (prinl Foos: (mapcar '((X) (prinl X)) (foos '+Foo))) # *2a* # (prinl Foos: (mapcar '((X) (prinl (type X))) (foos '+Foo))) # *2b* (prinl Foos: (mapcar '((X) (show X)) (foos '+Foo))) # *2c* (show '+Foo) ==8X== The idea is, that every instance get an id generated by a counter implemented as class variable 'N'. Then the constructor will register the instance in a assoc list also held by a class variable too 'Foos'. If you execute the code as is, an error will issued at *2c*, that the message 'show' is not understood. But if * I use *1b* and *2a* instead of *1c* and *2c* the correct id stored in the CAR of every element in the assoc list will be printed. * I use *1c* and *2b* instead, a type of +Foo will be reported for every instance held in the CDR of every association. * However, using *1a* instead of *1b* or *1c* will get me nowhere at all, despite I think it should have worked :-( To summarize, *1a* will not deliver, what I expect, but *1b* and *1c* seem to return what I want! Asking for the type of every instance held in the association list *2b* will answer +Foo correctly. But sending a 'show' to every instance (*2c*) will repsond with Bad message. So please enlight me, where is my stumble block? What did I wrong? Thanks and ciao, cle. -- UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe
Pilog: How to call a predicat?
Alexander Burger wrote: Hi Cle, Hi Alex, (...) But please note that there is one difference (or bug?) that Jon Kleiser found out about two years ago, and which I could not resolve: Anonymous variables ('@' in Pilog, '_' in Prolog) may not work as expected, when there is more than one of them in a complex rule, with each in a different context. I could not find a solution for that problem, and finally decided to live with it. I hope this is acceptable. urghs! This is a severe difference from Prolog. I would call it a bug ;-) But I do not know, if it is acceptable or if it comes into my way and make me stumble. But anyway, the most important thing is, to *know* about that restriction! Then -- perhaps -- one can solve or work-around it ... so, thank you for this hint! Now coming to another problem, I am already fiddle for several hours now. There is no Pilog 'retract'. So I decided to implement one. But I would like it to have the same semantic as in Prolog. In Prolog, 'retract' will first try to match and bind a clause, and then remove that clause from the database. Something like this: foo(1). foo(2). foo(3). retract(foo(N)), print(N), nl. Would try to match the clause foo(N). Success with foo(1). Therefore N would be bound to 1 and the clause foo(1) would be retracted. For this, however, I would have to be able to pass a predicate to 'retract' execute it and retract afterwards. If I try it interactively I can perform the operation like this: (be foo (1)) (be foo (2)) (be foo (3)) (? (@CL list 'foo '(@N)) (equal (@P . (@A)) @CL) (call @P . @A) (@ retract (- @CL)) Here the predicate I want to retract is the first one unifying with '(foo @N)'. This should be the first one '(foo 1)'. So '@N' is bound to '1' and the corresponding clause is retracted. This works as I expect! But I seem not to be able to get the code into another clause. I tried it like this: (be retract (@CL) (equal (@P . (@A)) @CL) (call @P . @A) (@ retract (- @CL)) ) But this does not work. If I try (? (retract (foo (@N '@N' got not bound to anything, an no fact was retracted. I have tried several other implementations of 'retract' but I cannot get it to work. So perhaps you can shed any light over me, what I do miss? Thanks and ciao, Cle. --000509060708050706030409 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN html head meta content=text/html; charset=UTF-8 http-equiv=Content-Type title/title /head body bgcolor=#ff text=#00 br br Alexander Burger wrote:br span style=white-space: pre;gt; Hi Cle,br /spanbr Hi Alex,br span style=white-space: pre;br (...)/spanbr br span style=white-space: pre;gt; But please note that there is one difference (or bug?) that Jonbr gt; Kleiser found out about two years ago, and which I could notbr gt; resolve:br gt; br gt; Anonymous variables ('@' in Pilog, '_' in Prolog) may not work as br gt; expected, when there is more than one of them in a complex rule,br gt; with each in a different context.br gt; br gt; I could not find a solution for that problem, and finally decided to br gt; live with it. I hope this is acceptable.br /spanbr urghs! This is a severe difference from Prolog. I would call it a bug ;-) But I do not know, if it is acceptable or if it comes into my way and make me stumble.br br But anyway, the most important thing is, to *know* about that restriction! Then -- perhaps -- one can solve or work-around it ... so, thank you for this hint!br br Now coming to another problem, I am already fiddle for several hours now. There is no Pilog 'retract'. So I decided to implement one. But I would like it to have the same semantic as in Prolog. In Prolog, 'retract' will first try to match and bind a clause, and then remove that clause from the database. Something like this:br br foo(1).br foo(2).br foo(3).br br retract(foo(N)), print(N), nl.br br Would try to match the clause foo(N). Success with foo(1). Therefore N would be bound to 1 and the clause foo(1) would be retracted.br br For this, however, I would have to be able to pass a predicate to 'retract' execute it and retract afterwards.br br If I try it interactively I can perform the operation like this:br br (be foo (1))br (be foo (2))br (be foo (3))br br (? (@CL list 'foo '(@N)) (equal (@P . (@A)) @CL) (call @P . @A) (@ retract (-gt; @CL))br br Here the predicate I want to retract is the first one unifying with '(foo @N)'. This should be the first one '(foo 1)'. So '@N' is bound to '1' and the corresponding clause is retracted.br br This works as I expect!br br But I seem not to be able to get the code into another clause. I tried it like this:br br (be retract (@CL)br (equal (@P . (@A)) @CL)br (call @P . @A)br (@ retract (-gt; @CL)) )br br But this does not work. If I trybr br
Re: Pilog: How to call a predicat?
Alexander Burger wrote: Hi Cle, Hi Alex, (...) Yes, the work-around is easy: Just use variables '@1', '@2' instead of '@'. It is just rather inelegant, and may produce unwanted output :-( jupp, so I will have a look at this, if this problem will bite me one day :-) The next problem seems rather hairy: (? (@CL list 'foo '(@N)) (equal (@P . (@A)) @CL) (call @P . @A) (@ retract (- @CL)) ... (be retract (@CL) (equal (@P . (@A)) @CL) (call @P . @A) (@ retract (- @CL)) ) It works if you use ... (equal (@P (@A)) @CL) (call @P @A) ... and ... (equal (@P (@A)) @CL) (call @P @A) ... A ... E ... :-O But my interactive line (? (...)) *did* work correctly as I wrote it. Only if I try to bring it into another clause by defining 'retract' it will not work :-/ And I tried your example as follow: (? (assertz (foo (1 1))) (? (assertz (foo (2 2))) (? (assertz (foo (3 3))) (be retract (@CL) (equal (@P (@A)) @CL) (call @P @A) (@ retract (- @CL)) ) it will *not* work with (? (retract (foo (@N @C nor (? (retract (foo @N @C))) I would like, to implement the first syntax above, as that match with the 'assertz' predicate. But don't ask me why! 'call' seems rather tricky, and I don't remember how and why I implemented it in that way (about 15 years ago) :-( Urghs ... then if you do not know, how I can get my 'retract' to work properly, I will have to look much more deeply into 'call' to understand it ... but the hope dies last ;-) (...) Ciao, Cle. -- UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe
Re: Pilog: does 'or' not backtrack?
Alexander Burger wrote: (...) 'or' takes not singular expressions, but whole clause bodies in each argument, to allow the implicit 'and' of Prolog. Thus, an additional level of parentheses is required. A working version would be: (be bT (@N) (or ((t1 @N)) ((t2 @N))) ) Helpful as ever! Thank you. With that explanation I eventually got also my 'assertz' got right! Previously it did not assert my desired clause. But you explanation above let me realize, that there too, a extra pair of parentheses were lacking ... :-) Cheers, - Alex Ciao, Cle. -- UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe
Re: Pilog: Does NIL successfully unify with (@H . @T)?
Alexander Burger wrote: Hi Cle, Hi Alex, although not intended so, it seems I mutate the picoLisp mailing list into a Pilog mailing list ;-) Which is a good thing. This way we produce at last some Pilog documentation ;-) nice you see it that way :-) (be attributes ((@H) @L @V) T (member (@H @V) @L) ) (be attributes ((@H . @) @L @V) (member (@H @V) @L) ) (be attributes ((@ . @T) @L @V) T (attributes @T @L @V) ) ... (? (attributes (b c) ((a 1) (b 2) (c 3)) @V)) ... good! But if I comment out the first rule, the Pilog interpreter gets into an endless loop, I have to terminate explicitely. Hmm, I cannot reproduce that. It works both with and without the first rule. Stupid me! Now I also cannot reproduce it! That is more than strange ... or perhaps ... perhaps I did execute it with the ./p script and did not hit the extra Enter afterwards? I have no another explanation, why it does work now ... sorry for the noise I made ... :-( BTW, let me explain a debugging aid in Pilog: You can trace the matching process for individual rules (similar to (trace 'fun) in Lisp) if you write the names of the rules you like to trace between the '?' and the first expression: : (? attributes (attributes (b c) ((a 1) (b 2) (c 3)) @V)) 1 (attributes (b c) ((a 1) (b 2) (c 3)) @V) @V=2 2 (attributes (b c) ((a 1) (b 2) (c 3)) @V) 1 (attributes (c) ((a 1) (b 2) (c 3)) @V) @V=3 2 (attributes (c) ((a 1) (b 2) (c 3)) @V) - NIL : The numbers preceding the trace output indicate which one of the 'attributes' rule matched. That is *really* nice! This will be very helpful in my future investigations. Thank you! :-) Cheers, - Alex Ciao, Cle. --040801020606010302090602 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN html head meta content=text/html; charset=ISO-8859-1 http-equiv=Content-Type /head body text=#00 bgcolor=#ff br br Alexander Burger wrote: blockquote cite=mid:20091125072012.gc16...@software-lab.de type=cite pre wrap=Hi Cle, /pre /blockquote br Hi Alex,br br blockquote cite=mid:20091125072012.gc16...@software-lab.de type=cite blockquote type=cite pre wrap=although not intended so, it seems I mutate the picoLisp mailing list into a Pilog mailing list ;-) /pre /blockquote pre wrap=! Which is a good thing. This way we produce at last some Pilog documentation ;-) /pre /blockquote br nice you see it that way :-)br br blockquote cite=mid:20091125072012.gc16...@software-lab.de type=cite blockquote type=cite pre wrap= (be attributes ((@H) @L @V) T (member (@H @V) @L) ) (be attributes ((@H . @) @L @V) (member (@H @V) @L) ) (be attributes ((@ . @T) @L @V) T (attributes @T @L @V) ) .. (? (attributes (b c) ((a 1) (b 2) (c 3)) @V)) .. good! But if I comment out the first rule, the Pilog interpreter gets into an endless loop, I have to terminate explicitely. /pre /blockquote pre wrap=! Hmm, I cannot reproduce that. It works both with and without the first rule. /pre /blockquote br Stupid me! Now I also cannot reproduce it! That is more than strange .. or perhaps ... perhaps I did execute it with the ./p script and did not hit the extra Enter afterwards? I have no another explanation, why it does work now ... sorry for the noise I made ... :-(br br blockquote cite=mid:20091125072012.gc16...@software-lab.de type=cite pre wrap=BTW, let me explain a debugging aid in Pilog: You can trace the matching process for individual rules (similar to (trace 'fun) in Lisp) if you write the names of the rules you like to trace between the '?' and the first expression: : (? attributes (attributes (b c) ((a 1) (b 2) (c 3)) @V)) 1 (attributes (b c) ((a 1) (b 2) (c 3)) @V) @V=2 2 (attributes (b c) ((a 1) (b 2) (c 3)) @V) 1 (attributes (c) ((a 1) (b 2) (c 3)) @V) @V=3 2 (attributes (c) ((a 1) (b 2) (c 3)) @V) -gt; NIL : The numbers preceding the trace output indicate which one of the 'attributes' rule matched. /pre /blockquote br That is *really* nice! This will be very helpful in my future investigations. Thank you! :-)br br blockquote cite=mid:20091125072012.gc16...@software-lab.de type=cite pre wrap=Cheers, - Alex /pre /blockquote br Ciao,br Cle.br br /body /html --040801020606010302090602-- -- UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe
Re: Probably solved [Was: picoLisp under MacOS/X 10.6 SIG-N
Alexander Burger wrote: Hi Cle, Hi Alexander, (...) I see. The unit tests are a little special. As they need a well-defined environment to operate correctly, they have to be started in a certain way. It is written as a comment in the 5th line of lib/test.l: # $(/bin/pwd)/p lib/test.l -bye This makes sure that 'Home' has a value that suits later tests which compare with the result of (pwd). urghs! I had seen this line, but I somehow totally ignored the $(pwd) hint! Sorry for the noise I made. :-( (...) Not wrong, but they would be useful only in the context of these unit tests. In that sense, the unit tests are the problem, not the system itself. Yeah I could verify this now ... still much to learn about picoLisp for me, I guess :-} (...) But in test/src/net.l you fork a child process while dealing with that port. And as my MacBoot is a dual core, those processes get executed in parallel probably. So it may be, that the test in test/src/net.l was alread passes, but the port was still hold by the child, when test/lib.l tried to open it. So it failed. This is only a hypothesis, though ... Ah, right! This might be the problem. The child process in test/src/net.l sleeps for 400 milliseconds before it terminates. If the other tests proceeded meanwhile, we might get a conflict. So I will follow your suggestion and change these ports. I uploaded a new picoLisp.tgz. If you have time, please check if the situation is improved. I have done so and I now can confirm, that you newest picoLisp will pass all unit tests under Snow Leopard (Intel), Leopard (PPC) and NetBSD (Intel) with flying colors :-) Only a small hint worth noting though, if building for NetBSD, one has to ensure, that 'gmake' is used instead of the binary 'make' that will *not* be GNU Make but some BSD make, which cannot work with those Makefile ... Thanks for your quick fixes ... (...) Ciao, Cle. --030009030601050802030004 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN html head meta content=text/html; charset=UTF-8 http-equiv=Content-Type /head body bgcolor=#ff text=#00 br br Alexander Burger wrote:br span style=white-space: pre;gt; Hi Cle,br /spanbr Hi Alexander,br br span style=white-space: pre;(...)/spanbr br span style=white-space: pre;gt; I see. The unit tests are a little special. As they need abr gt; well-defined environment to operate correctly, they have to bebr gt; started in a certain way. It is written as a comment in the 5th linebr gt; of lib/test.l:br gt; br gt; # $(/bin/pwd)/p lib/test.l -byebr gt; br gt; This makes sure that 'Home' has a value that suits later tests which br gt; compare with the result of (pwd).br /spanbr urghs! I had seen this line, but I somehow totally ignored the $(pwd) hint! Sorry for the noise I made. :-(br br span style=white-space: pre;(...)/spanbr br span style=white-space: pre;gt; Not wrong, but they would be useful only in the context of thesebr gt; unit tests. In that sense, the unit tests are the problem, not thebr gt; system itself.br /spanbr Yeah I could verify this now ... still much to learn about picoLisp for me, I guess :-}br br span style=white-space: pre;(...)/spanbr br span style=white-space: pre;gt;gt; But in test/src/net.l you fork a child process while dealing withbr gt;gt; that port. And as my MacBoot is a dual core, those processes getbr gt;gt; executed in parallel probably. So it may be, that the test inbr gt;gt; test/src/net.l was alread passes, but the port was still hold bybr gt;gt; the child, when test/lib.l tried to open it. So it failed. This isbr gt;gt; only a hypothesis, though ...br gt; br gt; Ah, right! This might be the problem. The child process in br gt; test/src/net.l sleeps for 400 milliseconds before it terminates.br gt; If the other tests proceeded meanwhile, we might get a conflict.br gt; br gt; So I will follow your suggestion and change these ports.br gt; br gt; I uploaded a new picoLisp.tgz. If you have time, please check ifbr gt; the situation is improved.br /spanbr I have done so and I now can confirm, that you newest picoLisp will pass all unit tests under Snow Leopard (Intel), Leopard (PPC) and NetBSD (Intel) with flying colors :-)br br Only a small hint worth noting though, if building for NetBSD, one has to ensure, that 'gmake' is used instead of the binary 'make' that will *not* be GNU Make but some BSD make, which cannot work with those Makefile ...br br Thanks for your quick fixes ...br br (...)br br Ciao,br Cle.br br /body /html --030009030601050802030004-- -- UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe
How to use Pilog?
Hello, I try to get a grasp, how to use Pilog properly. As I thought it resembles Prolog but only with a Lisp-ish syntax, I tried to implement the both Prolog rules for member/2 and append/3 in Pilog. But I guess, I did not really understand Pilog properly, as I cannot get the definitions to work correctly. The Prolog definitions are: member(X, [X|_]). member(X, [_|T]) :- member(X, T). append([], L, L). append([H|L1], L2, [H|L3]) :- append(L1, L2, L3). I already fail defining a correct Pilog member. This is, what I already got: (be mymember (@ NIL) T) (be mymember (@X @L) (equal (- @X) (car (- @L (be mymember (@X @L) (mymember @X (cdr (- @L But if I try, for instance, (prove (goal '((mymember '2 '(1 2 3) it seems to run forever ... Can someone please shed some light on my, how to define member/2 and append/3 in Pilog properly? Thanks in advance ... Ciao, Cle. -- UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe
Re: How to use Pilog?
Alexander Burger wrote: Hi Cle, Hello Alex, (...) Thank you for the list of rules, this will be very helpful :-) (be member (@X (@X . @))) (be member (@X (@ . @Y)) (member @X @Y)) (be append (NIL @X @X)) (be append ((@A . @X) @Y (@A . @Z)) (append @X @Y @Z)) Wow, these are very streight forward. I should have anticipated, that (@H . @T) will replace [H|T] in Prolog. This is only logical :-( Thank you! (in fact, I copy/pasted that from lib/pilog.l:117 :-) Again another source I will have to dig into :-) (...) In the second clause you are doing it halfway correct. (- @X) is the way to access a Pilog binding in a Lisp expression. You can use a Lisp expression in a clause if that expression has a variable in its CAR, then the CDR should be Lisp. The second clause could be Ok, this rule I do not really understand, I think. What other sense does it make, to have a Pilog variable in the CAR of a clause, except to allow Lisp in its CDR? (be mymember (@X @L) (@ = (- @X) (car (- @L I guess here, the variable '@' stands only here to allow the Lisp function '=' to be used? The third clause, however, is difficult to get straight in this way, as 'mymember' is not a Lisp function. Ah okay! Because there is no Pilog variable in the CAR of the clause, I cannot use 'car' or 'cdr' in the clause. If, though, I use a dummy variable in the CAR to enable Lisp in the CDR, I wouldn't be able to call mymember, as it is not a Lisp function, yes? So it is better to use the standard Prolog method of supplying a pattern like (@X . @) or (@ . @Y) to split a list, as in the Pilog clauses above. Of course! As Pilog is so streight forward, I will use your construction. I like it much better than my attempt. I used it only my way, as I was not aware of the possibility you shown. But another question: Is it to be expected, if I start ./p and typing (be like (J M)) (? (like @A @B)) picoLisp seem to run forever? I have to explicitely interrupt it with ^C resulting in a bus error. If I use ./dbg, however, all runs as expected :-) I really need to document Pilog! I have it on my todo list, but currently I try to document the database classes first. This is important as well, of course. Hopefully you wouldn't mind me asking further noob questions about Pilog, though! :-} (...) Ciao, Cle. --000706040500020709030403 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN html head meta content=text/html; charset=UTF-8 http-equiv=Content-Type title/title /head body text=#00 bgcolor=#ff br br Alexander Burger wrote:br span style=white-space: pre;gt; Hi Cle,br /spanbr Hello Alex,br br (...)br br Thank you for the list of rules, this will be very helpful :-)br br span style=white-space: pre;gt; (be member (@X (@X . @))) /spanbr gt; span style=white-space: pre; (be member (@X (@ . @Y)) (member @X @Y))br gt; br gt; (be append (NIL @X @X))/spanbr gt; span style=white-space: pre; (be append ((@A . @X) @Y (@A . @Z))/span span style=white-space: pre;(append @X @Y @Z))br /spanbr Wow, these are very streight forward. I should have anticipated, that (@H . @T) will replace [H|T] in Prolog. This is only logical :-(br br Thank you!br span style=white-space: pre;br gt; (in fact, I copy/pasted that from lib/pilog.l:117 :-)br /spanbr Again another source I will have to dig into :-)br br (...)br br span style=white-space: pre;gt; In the second clause you are doing it halfway correct. (-gt; @X) isbr gt; the way to access a Pilog binding in a Lisp expression. You can usebr gt; a Lisp expression in a clause if that expression has a variable inbr gt; its CAR, then the CDR should be Lisp. The second clause could be/spanbr br Ok, this rule I do not really understand, I think. What other sense does it make, to have a Pilog variable in the CAR of a clause, except to allow Lisp in its CDR?br br span style=white-space: pre;gt; (be mymember (@X @L) (@ = (-gt; @X) (car (-gt; @Lbr /spanbr I guess here, the variable '@' stands only here to allow the Lisp function '=' to be used?br span style=white-space: pre;br gt; The third clause, however, is difficult to get straight in this way,br gt; as 'mymember' is not a Lisp function./spanbr br Ah okay! Because there is no Pilog variable in the CAR of the clause, I cannot use 'car' or 'cdr' in the clause. If, though, I use a dummy variable in the CAR to enable Lisp in the CDR, I wouldn't be able to call mymember, as it is not a Lisp function, yes?br br span style=white-space: pre;gt; So it is better to use the standard Prolog method of supplying abr gt; pattern like (@X . @) or (@ . @Y) to split a list, as in the Pilogbr gt; clauses above./spanbr br Of course! As Pilog is so streight forward, I will use your construction. I like it much better than my attempt. I used it only my way, as I was not aware of the possibility you shown.br br
Pilog: does 'or' not backtrack?
Hello, another question concerning Pilog. Suppose following senseless Prolog snippet: t1(1). t1(2). t1(3). t2(4). t2(5). t2(6). aT(N) :- t1(N). aT(N) :- t2(N). bT(N) :- t1(N) ; t2(N). Here the predicate aT/1 may be rewritten using the ';' operator as in bT/1. Now I have found, that Pilog offer a 'or' rule. But it seems, this does not resemble ';' of Prolog. Suppose the Pilog translation of the code above: (be t1 (1)) (be t1 (2)) (be t1 (3)) (be t2 (4)) (be t2 (5)) (be t2 (6)) (be aT (@N) (t1 @N)) (be aT (@N) (t2 @N)) (be bT (@N) (or (t1 @N) (t2 @N))) Now calling (? (aT @N)) is running like the Prolog version and therefore as I expected. But running (? (bT @N)) will return NIL at once. So I would like to ask, if 'or' works as intended or if there is a bug? Thanks in advance and ciao, Cle. -- UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe
Re: Probably solved [Was: picoLisp under MacOS/X 10.6 SIG-N
Alexander Burger wrote: Hi Cle, Hello Alexander, Alexander Burger wrote: Hi Cli, Oops, sorry ;-) Macht nischt! :-D (...) Now I'm wondering why you extended the setting of the 'Home' global in init(), to fall back to the current working directory if the first file argument doesn't contain a usable path pattern. Because in test/src/mail.l there is a unit test (test (path '@) (pack (pwd) '/)) that consistently failed before! I found, that if I start the unit tests via ./p lib/test.l -bye would result into a call like this using the script p: exec ./bin/picolisp ./lib.l @ext.l lib/test.l -bye Exactly the combination, that let 'Home' unset so the unit test failed. Now I assumed the following: if (the first file contains a '/' and does not begin with './') old handling that also considering absolute pathes and relative pathes not beginning with './' else assume the path is relative to the current working directory But perhaps my assumptions were wrong? Is this needed on the Mac? IMHO, it does not make sense for the purpose of 'Home' (i.e. being inserted in path names starting with '@'), because it is to make programs independent from the current working directory and find the installation directory when started from arbitrary locations. Is it needed on the Mac? I do not know! But as the 'p' script make all my calls to './' the old solution did not work. So I changed it. But perhaps my solution is also not correct! So could you perhaps elaborate a bit, what should be the correct behavior? If for instance started via ./p lib/test.l -bye ./p $(pwd)/lib/test.l -bye ./p ../picolisp/lib/test.l -bye (cd lib; ../p test.l -bye) PATH=$(pwd):$PATH p lib/test.l -bye Some of these cases still do not work correctly neither with the old solution nor with my work-around. So perhaps we should first specify a bit, how it should work correctly and then I can try to implement the solution? But anyhow, sorry, if I got it wrong this time! The other issue, the port conflict, is quite strange: test/src/net.l also use port , it seems that the port was not released back to the OS yet, when test/lib.l was running. Therfore it was still be used and couldn't be bound again. Then we have another bug on the Mac perhaps. On my system, a port can be reused after it was closed: (... test sequence snipped ...) What happens if you try these things in the REPL? It works correctly! No problem at all! But in test/src/net.l you fork a child process while dealing with that port. And as my MacBoot is a dual core, those processes get executed in parallel probably. So it may be, that the test in test/src/net.l was alread passes, but the port was still hold by the child, when test/lib.l tried to open it. So it failed. This is only a hypothesis, though ... Cheers, - Alex Ciao, Cle. --080103040309050501040702 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN html head meta content=text/html; charset=UTF-8 http-equiv=Content-Type title/title /head body bgcolor=#ff text=#00 br br Alexander Burger wrote:br span style=white-space: pre;gt; Hi Cle,br /spanbr Hello Alexander,br span style=white-space: pre;br gt;gt; Alexander Burger wrote:br gt;gt;gt; Hi Cli,br gt; br gt; Oops, sorry ;-)br /spanbr Macht nischt! :-Dbr br span style=white-space: pre;(...)/spanbr br span style=white-space: pre;gt; Now I'm wondering why you extended the setting of the 'Home' globalbr gt; in init(), to fall back to the current working directory if the firstbr gt; file argument doesn't contain a usable path pattern./spanbr br Because in test/src/mail.l there is a unit test (test (path '@) (pack (pwd) '/)) that consistently failed before! I found, that if I start the unit tests viabr br ./p lib/test.l -byebr br would result into a call like this using the script p:br br exec ./bin/picolisp ./lib.l @ext.l lib/test.l -byebr br Exactly the combination, that let 'Home' unset so the unit test failed. Now I assumed the following:br br if (the first file contains a '/' and does not begin with './')br old handling that also considering absolute pathes andbr relative pathes not beginning with './'br elsebr assume the path is relative to the current working directorybr br But perhaps my assumptions were wrong?br br span style=white-space: pre;/spanspan style=white-space: pre;gt; Is this needed on the Mac? IMHO, it does not make sense for thebr gt; purpose of 'Home' (i.e. being inserted in path names starting withbr gt; '@'), because it is to make programs independent from the currentbr gt; working directory and find the installation directory when startedbr gt; from arbitrary locations./spanbr br Is it needed on the Mac? I do not know! But as the 'p' script make all my calls to './' the old solution did not work. So I changed it. But perhaps my
Probably solved [Was: picoLisp under MacOS/X 10.6 SIG-N everytime?]
Alexander Burger wrote: Hi Cle, Hi Alexander, unfortunately, we see problems on Mac OS since quite some time. You'll see that if you search in the archive of this mailing list (http://www.mail-archive.com/picolisp@software-lab.de). I had already seen this, but those problems dealt with being not able to build picoLisp though. Therefore I had the hope, that my problem perhaps is already solved! :-} I don't have a Mac myself. So I'm still hoping that some of the Mac users fires up a debugger and helps, but no results so far :-( Ok! Today I had give it a try and finally I was able to patch and build picoLisp to being runable under Snow Leopard passing all unit tests in lib/test.l and running doc/hello.l and doc/family.l too :-) I have attached the patch necessary to fix all glitches for Snow Leopard. I have tested the changes against Snow Leopard and NetBSD and they work fine! I intend to have a look, if they run under Leopard (MacOS/X 10.5) tomorrow if I can manage to install Xcode on my PPC machine. BTW: If you duplicate the OpenBSD section in the src/Makefile and replace OpenBSD by NetBSD, you can add another platform picoLisp is running onto :-D The attached patch was made against the development version downloaded as picoLisp.tgz from your homepage. The patch was applied as: tar xzf picoLisp.tgz cd picoLisp patch -p0 ../picoLisp.patch (cd src; make clean picolisp) ./p lib/test.l -bye I hope, I did not break your coding style too much via the patch ... Best regards and thanks for picoLisp ... :-) Ciao, Cle. (...) Index: src/Makefile === --- src/Makefile +++ src/Makefile @@ -33,11 +33,11 @@ STRIP = strip else ifeq ($(shell uname), Darwin) OS = Darwin PICOLISP-FLAGS = -m32 -lc -lm -ldl - DYNAMIC-LIB-FLAGS = -dynamiclib -undefined dynamic_lookup + DYNAMIC-LIB-FLAGS = -dynamiclib -undefined dynamic_lookup -m32 STRIP = : else ifeq ($(shell uname -o), Cygwin) OS = Cygwin DYNAMIC-LIB-FLAGS = -shared Index: src/main.c === --- src/main.c +++ src/main.c @@ -2,10 +2,31 @@ * (c) Software Lab. Alexander Burger */ #include pico.h +/* Globals declared in pico.h */ +int Signal, Chr, Slot, Spkr, Mic, Hear, Tell, Children, ExtN; +char **AV, *AV0, *Home; +child *Child; +heap *Heaps; +cell *Avail; +stkEnv Env; +catchFrame *CatchPtr; +struct termios OrgTermio, *Termio; +int InFDs, OutFDs; +inFile *InFile, **InFiles; +outFile *OutFile, **OutFiles; +int (*getBin)(void); +void (*putBin)(int); +any TheKey, TheCls, Thrown; +any Alarm, Line, Zero, One, Intern[IHASH], Transient[IHASH], Extern[EHASH]; +any ApplyArgs, ApplyBody, DbVal, DbTail; +any Nil, DB, Meth, Quote, T; +any Solo, PPid, Pid, At, At2, At3, This, Dbg, Zap, Ext, Scl, Class; +any Run, Hup, Sig1, Sig2, Up, Err, Msg, Uni, Led, Tsm, Adr, Fork, Bye; + /* Globals */ static int TtyPid; static word2 USec; static struct timeval Tv; static bool Tio, Jam; @@ -633,11 +654,11 @@ else { if (n) memcpy(buf, Home, n); strcpy(buf + n, lib/), strcpy(buf + n + 4, nm); } - if (!(h = dlopen(buf, RTLD_LAZY | RTLD_GLOBAL)) || !(h = dlsym(h,p))) + if (!(h = dlopen(buf, RTLD_NOW | RTLD_GLOBAL)) || !(h = dlsym(h,p))) return NO; val(x) = box(num(h)); } return YES; } @@ -1061,10 +1082,17 @@ if (*av[i] != '-') { if ((p = strrchr(av[i], '/')) !(p == av[i]+1 *av[i] == '.')) { Home = malloc(p - av[i] + 2); memcpy(Home, av[i], p - av[i] + 1); Home[p - av[i] + 1] = '\0'; + } + else if ((p = getcwd(NULL,0)) != NULL) { +int len = strlen(p); +Home = malloc(len + 2); +memcpy(Home, p, len); +Home[len] = '/'; +Home[len + 1] = '\0'; } break; } AV0 = *av++; AV = av; Index: src/pico.h === --- src/pico.h +++ src/pico.h @@ -234,512 +234,512 @@ /* External symbol access */ #define Fetch(ex,x) if (isExt(x)) db(ex,x,1) #define Touch(ex,x) if (isExt(x)) db(ex,x,2) /* Globals */ -int Signal, Chr, Slot, Spkr, Mic, Hear, Tell, Children, ExtN; -char **AV, *AV0, *Home; -child *Child; -heap *Heaps; -cell *Avail; -stkEnv Env; -catchFrame *CatchPtr; -struct termios OrgTermio, *Termio; -int InFDs, OutFDs; -inFile *InFile, **InFiles; -outFile *OutFile, **OutFiles; -int (*getBin)(void); -void (*putBin)(int); -any TheKey, TheCls, Thrown; -any Alarm, Line, Zero, One, Intern[IHASH], Transient[IHASH], Extern[EHASH]; -any ApplyArgs, ApplyBody, DbVal, DbTail; -any Nil, DB, Meth, Quote, T; -any Solo, PPid, Pid, At, At2, At3, This, Dbg, Zap, Ext, Scl, Class; -any Run, Hup, Sig1, Sig2, Up, Err, Msg, Uni, Led, Tsm, Adr, Fork, Bye; +extern int Signal
picoLisp under MacOS/X 10.6 SIG-N everytime?
Hello, I am new to picoLisp. I investigate, if I can use it for a tool that could replace another one internal used currently wirtten in C++. picoLisp seem to be a nice fit. But unfortunately I cannot get it to run properly under Snow Leopard! To build picoLisp correctly I had to add a '-m32' switch to the DYNAMIC-LIB-FLAGS in src/Makefile. Now I can compile and execute picoLisp and playing with it via e.g. dbg.l. But if I try to start a more complex example like e.g. doc/hello.l or doc/family.l as explained in the documentation, picoLisp will start up fine, but if I try to access the application via a browser over http://127.0.0.1:8080, picoLisp will complain on the console with some 36829 SIG-10 Sometimes one of such a line, sometimes a few ones. And it is not SIG-10 every time, but sometimes it will also come up with e.g. SIG-5 or such ... Do anybody have an idea what the reason for this could be? Any hint, what I can do to spot the problem? Thanks in advance for any idea you may have ... Regards, Cle. -- UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe
Subscribe
Hello cle cle-picol...@qiao.in-berlin.de :-) You are now subscribed -- UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe