Re: Mips / LibreCMC build

2017-02-08 Thread Christopher Howard
I added a wiki page here:

http://picolisp.com/wiki/?picolisponmips

On 02/08/2017 04:57 AM, Mike Pechkin wrote:
> 
> 
> On Wed, Feb 8, 2017 at 3:45 PM, Christopher Howard
> >
> wrote:
> 
> I would like to share the build with the world. Did you
> guys want to host the build somehow, or did you want me to host
> elsewhere and then link to my repo?
> 
> 
> ​You could​
> ​ create page on
> http://picolisp.com/wiki
> with anounce here and or reddit.com/r/lisp 
> 
> ​Mike
> ​
> 

-- 
https://qlfiles.net
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: binding free symbols in a lambda definition

2017-02-08 Thread pd
Hi Alex

> The classical curry in picolisp is what Alex has defined a few emails
> > before ;-)
>
> I never saw a use for the classical curry, so I (ab)used this catchy name
> :)
>
> Can you give an example where it is useful in PicoLisp?
>

I'm a newbie to picolisp I don't know enough picolisp to state what is
useful or not.

But curryfied functions are very useful in a lot of situations like
processing lists like mapping (mapcar),  folding...
They are also very useful in function composition which in turn is useful
again in list mapping and so on and also to define functions easier and
clearly
And also thery are useful in defining functons in terms of another
functions in a clear, comprehensive and sucint way.

Considering curry defined as Alex's ClassiCurry in terms of picolisp (let's
call it curri here)

  (de curri (Fun)
  (let Par (list (caar Fun))
 (list Par
(cons 'curry Par (cdar Fun) (cdr Fun)) ) ) )

For example, consider a function like this:

(de task (Action A B) (Action A B))

and you provide a bunch of functions as interface to the previous one:

(de plus (A B) (task + A B))
(de minus (A B) (task - A B))
(de power (A B) (task ** A B))
..

with curry (really here curri) you can better define the interface
functions as:

(setq plus ((curri task) +))
(setq minus ((curri task) -))
(setq power ((curri task) **))
..

this way is shorter, clearer and less error-prone and easy to mantain
because if signature of function task changes the interface functions are
not affected at all (provided the first arg continues to be the action)

Also curry functions and partial application are useful to process elements
of a list with functions with many arguments, like

(mapcar ((curri **) 2)  (2 3 4))# equivalent to (mapcar
'((X) (** 2 X)) (2 3 4))

(setq lstLen ((curri mapcar) length))   # equivalent to (de lstLen
(lst) (mapcar length lst))
(lstLen '((1) (2 3 4) (2 3)))
(((curri mapcar) length) '((1) (2 3 4) (2 3)))  # equivalent to (mapcar
'((L) (length L)) '((1) (2 3 4) (2 3)))


>
> > >((X) '((Y) (+ X Y)))
> > ...
> > The reason for this expression being completely useless in picolisp *I
> > think* is the use of quote as an alias for lambda thus in practise
> > protecting them from evaluation and binding
>
> This is not the reason. Quote and lambda are abselutely equivalent here.
>
> You could do
>
>(setq lambda quote)
>
> and then
>
>   ((X) (lambda (Y) (+ X Y)))
>
>
I know that, but I pretend to mean another thing, sadly without clarity


and have the same result, i.e. a function returning ((Y) (+ X Y)), which is
> a
> correct, legal PicoLisp function accepting an single parameter Y and
> returning a
> sum. The quote (or lambda) is gone immediately when returning this
> function.
>
> It may seem useless to you because PicoLisp uses dynamic binding (X is
> evaluated
> when this function *runs*), but you expected static binding (X is bound to
> the
> value from the environment when this function is *built*).
>
> The latter is done in the 'classiCurry' example in my last mail using the
> PioLisp 'curry'.
>

yes, I have to study your classiCurry function to clearly understand how it
works and yes maybe I'm a bit confused about dynamic binding usefulness due
to my static binding background

But let me try to better explain myself...

Writing this code:

(let N 4 (print N))

binds symbol N to value 4 inside print expression and so it prints 4, this
is what we expect of let binding behaviour

same for this code:

(let N 4 (+ 1 N))

we expect to return 5

In a coherent way we expect this code:

(let N 4 ((X) (+ X N)))  # erroneus code, I know it!

to return a function which adds 4 to its parameter   (and it would do it if
it doesn't throw a X undefined error)

But here the problem is we cannot write an anonymous function (a lambda)
this way, we *must* quote it:

(let N 4 '((X) (+ X N)))

but now the quoting has the effect of not evaluating the lambda and thus
preserving it from let symbol binding, this is an undesiderable effect in
my opinion

So how to avoid this undesiderable side effect?  well, first, we have to
kow why it happens, i.e why we must quote the lambda? the answer to protect
it from calling

Calling is what happen to a function when its evaluated, so when let
expression is evaluated, eval see its a function and calls it but it finds
it needs one argument and there's none
so fails with X undefined error, the solution to avoid calling the function
is just avoid evaluating the function and thus the need of quotation with
the bad side effect we've just seen

So what to do? (from here I'm just reasoning loud) well, the key is to
separate function evaluation from function calling, what if there would be
a mark for type function?
in a way the steps in let expression evaluation were similar to this:

1- read the whole let expression
2- read-macros get executed inmmediately (really I think this is part of
step 1)
3- perform the bindings in 

Re: binding free symbols in a lambda definition

2017-02-08 Thread Alexander Burger
On Wed, Feb 08, 2017 at 06:37:17PM +0100, pd wrote:
> Picolisp curry function does not follow the pattern, its domain is
> completely different and also its image. In other words, you call classical
> curry passing it a function argument but you call picolisp curry passing it
> several arguments to replace certain symbols inside expressions. It's a
> different kind of animal ;-)

Right. Actually, it does not necessarily *replace* certain symbols inside
expressions. It does so only if you pass "pattern variables", see
http://software-lab.de/doc/refP.html#pat?

In the normal, general, case, an environment using 'job' is built. This is
called a "closure" is in statically binding systems. I did not want to call the
PicoLisp 'curry' function a closure, because it returns a *function* while a
closure is not a function but the combination of a piece of code with an
environmennt (i.e. a 'job' in PicoLisp).



> The classical curry in picolisp is what Alex has defined a few emails
> before ;-)

I never saw a use for the classical curry, so I (ab)used this catchy name :)

Can you give an example where it is useful in PicoLisp?


> >((X) '((Y) (+ X Y)))
> ... 
> The reason for this expression being completely useless in picolisp *I
> think* is the use of quote as an alias for lambda thus in practise
> protecting them from evaluation and binding

This is not the reason. Quote and lambda are abselutely equivalent here.

You could do

   (setq lambda quote)

and then

  ((X) (lambda (Y) (+ X Y)))

and have the same result, i.e. a function returning ((Y) (+ X Y)), which is a
correct, legal PicoLisp function accepting an single parameter Y and returning a
sum. The quote (or lambda) is gone immediately when returning this function.

It may seem useless to you because PicoLisp uses dynamic binding (X is evaluated
when this function *runs*), but you expected static binding (X is bound to the
value from the environment when this function is *built*).

The latter is done in the 'classiCurry' example in my last mail using the
PioLisp 'curry'.

♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: binding free symbols in a lambda definition

2017-02-08 Thread Erik Gustafson
Ahh, I see what you mean. I was not as familiar with the classical curry,
as I was first introduced to the concept through PL. Thanks for clarifying
with the great write-up!

On Feb 8, 2017 11:45 AM, "pd"  wrote:

> Thanks for your replies, I think your "subst" is exactly the same to
> newlisp "expand"
>
> But picolisp curry function doesn't do that, it simply returns a lambda
>> with 1 parameter having the other one properly substituted with its value
>> thus making impossible to partially apply the returned function
>>
>>
>> I still think 'curry' is what you want.
>>
>>
>> As far as partial application, wasn't 'adder' an example of that?
>>
>>: (adder 3)
>>-> ((X) (+ X 3))  # partial application
>>: ((adder 3) 7)   # used as function call
>>-> 10
>>
>>
> yes, adder is an example of partial & total application but now we're
> talking about the result of using curry (here the adder function) which
> allows partial application.
>
> But when talking about the curry function itself the problem is the domain
> of function, in classical curry the domain are functions of n arguments
> (usually n>1) and the image are also functions with exactly 1 argument.
>
> Picolisp curry function does not follow the pattern, its domain is
> completely different and also its image. In other words, you call classical
> curry passing it a function argument but you call picolisp curry passing it
> several arguments to replace certain symbols inside expressions. It's a
> different kind of animal ;-)
>
> So you cannot apply picolisp curry to any general function, as you do in
> classical curry, you must create a picolisp curry call ad hoc to get a
> expected function returned
>
> With a classical curry function you can use (call 'f) to get a curryfied
> version of function f which takes only one argument and returns a function
> who takes only one argument and returns a function who... (supposing f has
> n arguments you have n levels on "indirection"), with picolisp curry you
> cannot call it like (call 'f) being f a general function (defined with de)
>
> The classical curry in picolisp is what Alex has defined a few emails
> before ;-)
>
>
>
>> I'm not sure that a structure such as
>>
>>((X) '((Y) (+ X Y)))
>>
>> would be very useful in PL, though it could certainly be built with our
>> friends 'fill' or 'macro'. But I'm also not sure I understood your question
>> entirely.
>>
>> What that helpful at all?
>>
>>
>>
> Absolutely unuseful in picolisp, what I tried to express is the concept of
> functions returning functions characteristic of curryfied functions in
> picolisp syntax.
>
> The reason for this expression being completely useless in picolisp *I
> think* is the use of quote as an alias for lambda thus in practise
> protecting them from evaluation and binding
>
>
>
>
>
> --
> Andrés
>
> *~ La mejor manera de librarse de la tentación es caer en ella**. ~ Oscar
> Wilde* ~
>


Re: Modularization / Shared Libraries

2017-02-08 Thread Erik Gustafson
Thank you. Could you explain this code:

(load
   "@test/src/main.l"
   "@test/src/apply.l"
   "@test/src/flow.l"
   "@test/src/sym.l"
   "@test/src/subr.l"
   "@test/src/big.l"
   "@test/src/io.l"
   "@test/src/db.l"
   "@test/src/net.l"
   "@test/src/ext.l"
   "@test/src/ht.l" )

How is the "@" character being used here?


In this case it is for "home directory substitution". The PL interpreter
remembers the pathname from which it was called and that path can be
referenced using '@'.

Say you have a local PL installation residing in the directory
/home/you/picoLisp and you want to start the interpreter with the HTTP
library loaded. You can just write

  [picoLisp]$ ./pil @lib/http.l +

Instead of

   [picoLisp]$ ./pil /home/you/picoLisp/lib/http.l +

Kind of a convoluted example, maybe.

So all the '@test/...'s from above mean to load different files from the
'test' directory of the particular PL installation that was called.

'@' is a particularly context sensitive symbol in PL. Here's a quick
reference to help you sort out the different uses:

http://picolisp.com/wiki/?AtMark

Best,
Erik


Re: binding free symbols in a lambda definition

2017-02-08 Thread pd
Thanks for your replies, I think your "subst" is exactly the same to
newlisp "expand"

But picolisp curry function doesn't do that, it simply returns a lambda
> with 1 parameter having the other one properly substituted with its value
> thus making impossible to partially apply the returned function
>
>
> I still think 'curry' is what you want.
>
>
> As far as partial application, wasn't 'adder' an example of that?
>
>: (adder 3)
>-> ((X) (+ X 3))  # partial application
>: ((adder 3) 7)   # used as function call
>-> 10
>
>
yes, adder is an example of partial & total application but now we're
talking about the result of using curry (here the adder function) which
allows partial application.

But when talking about the curry function itself the problem is the domain
of function, in classical curry the domain are functions of n arguments
(usually n>1) and the image are also functions with exactly 1 argument.

Picolisp curry function does not follow the pattern, its domain is
completely different and also its image. In other words, you call classical
curry passing it a function argument but you call picolisp curry passing it
several arguments to replace certain symbols inside expressions. It's a
different kind of animal ;-)

So you cannot apply picolisp curry to any general function, as you do in
classical curry, you must create a picolisp curry call ad hoc to get a
expected function returned

With a classical curry function you can use (call 'f) to get a curryfied
version of function f which takes only one argument and returns a function
who takes only one argument and returns a function who... (supposing f has
n arguments you have n levels on "indirection"), with picolisp curry you
cannot call it like (call 'f) being f a general function (defined with de)

The classical curry in picolisp is what Alex has defined a few emails
before ;-)



> I'm not sure that a structure such as
>
>((X) '((Y) (+ X Y)))
>
> would be very useful in PL, though it could certainly be built with our
> friends 'fill' or 'macro'. But I'm also not sure I understood your question
> entirely.
>
> What that helpful at all?
>
>
>
Absolutely unuseful in picolisp, what I tried to express is the concept of
functions returning functions characteristic of curryfied functions in
picolisp syntax.

The reason for this expression being completely useless in picolisp *I
think* is the use of quote as an alias for lambda thus in practise
protecting them from evaluation and binding





-- 
Andrés

*~ La mejor manera de librarse de la tentación es caer en ella**. ~ Oscar
Wilde* ~


Re: Modularization / Shared Libraries

2017-02-08 Thread Alexander Burger
Hi Christopher,

> Thank you. Could you explain this code:
> 
> (load
>"@test/src/main.l"
>"@test/src/apply.l"
>...
> 
> How is the "@" character being used here? The reference documentation
> mentions the wildcard character in conjunction with match and fill, but
> I'm not clear on what it means here.

This is indeed not obvious.

"@" has special meaning in many different contexts. There is even an article
about them: http://picolisp.com/wiki/?atmark - the above use case is mentioned
under "path names".

The primary documentation is in http://software-lab.de/doc/ref.html#invoc in the
paragraph:

   In any case, the directory part of the first file name supplied (normally,
   the path to "lib.l" as called by 'pil') is remembered internally as the
   PicoLisp Home Directory. This path is later automatically substituted for any
   leading "@" character in file name arguments to I/O functions (see path).

or also in http://software-lab.de/doc/refP.html#path

♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Modularization / Shared Libraries

2017-02-08 Thread Christopher Howard
Thank you. Could you explain this code:

(load
   "@test/src/main.l"
   "@test/src/apply.l"
   "@test/src/flow.l"
   "@test/src/sym.l"
   "@test/src/subr.l"
   "@test/src/big.l"
   "@test/src/io.l"
   "@test/src/db.l"
   "@test/src/net.l"
   "@test/src/ext.l"
   "@test/src/ht.l" )

How is the "@" character being used here? The reference documentation
mentions the wildcard character in conjunction with match and fill, but
I'm not clear on what it means here.

On 02/08/2017 04:47 AM, Mike Pechkin wrote:
> 
> 
> On Wed, Feb 8, 2017 at 3:20 PM, Christopher Howard
> >
> wrote:
> 
> Hi all, picolisp newbie here. I was trying to figure out how to
> "modularize" my code; there doesn't seem to be a module system built in,
> but the reference doc did mention support for shared libraries. A few
> questions:
> 
> 
> ​As I can understand you mix two different functions - load and native
> 
>  
> 
> 
> 1) On Gnu/Linux, how do you put code into a shared library?
> 
> 
> ​Look how builtin tests splits to files:​
> https://bitbucket.org/mmamkin/picolisp/src/e33e90fb0e11aa6cdb8634c8ef73b1dac5c1f60a/lib/test.l?at=default=file-view-default
> 
>  
> 
> 2) Where on the system does picolisp search for shared libraries?
> 
> 
> native searches in dirs from ldconfig -p​
> 
> 

-- 
Christopher Howard, Computer Assistant
Alaska Satellite Internet
3239 La Ree Way, Fairbanks, AK 99709
907-451-0088 or 888-396-5623 (toll free)
fax: 888-260-3584
mailto:christop...@alaskasi.com
http://www.alaskasatelliteinternet.com
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: unit testing?

2017-02-08 Thread dean
Hi Alex and Christophe
In Python that __name__ variable stops things like a local main proc from
executing altogether...when Python detects that the module in which it
exists no longer needs it because it is being loaded by a bigger program,
which accesses the module's code like the local main does i.e. The local
main is hidden from Python under such circumstances.

I was wondering about  the "once" situation toobecause I have
experienced "function redeclared" or some such popping up. If you're
telling me that such messages are inconsequential compared to the benefits
of developing in a way which causes that.that's fine by me because it's
easier to ignore the redeclaration messages than not :)

Because PL seems to allow forward referencing...I was
1 Putting all the scaffolding down the bottom with my local main so it's
all in the same place.
2 Commenting it all out...
3 Loading the module into the wider program and then
4 Comment the helper functions back in as PL reported their absence.
Obviously the local main stays commented out.
This seems fairly convenient but my interpretation of the above is I only
need to comment out the local main and if that's right that's great.

Thank you Chrostophe for the further explanation re Python.

Best Regards
Dean






On 8 February 2017 at 14:47, Christophe Gragnic  wrote:

> On Wed, Feb 8, 2017 at 12:13 PM, Alexander Burger 
> wrote:
> >> I'm thinking of Python's `if __name__ == '__main__' and Perl's unless
> >> (caller) {...}
> >
> > I don't know Python and Perl well enough. But perhaps 'once' is what you
> think
> > of?
> >
> >(once (load "xxx.l"))
>
> No, it's different.
>
> In Python there's a «magic» variable named __name__.
> As files can be:
> - imported from another script/module
> - interpreted directly from top leve
> it provides a trick to distinguish between those two ways to use a
> script/module.
> See here:
> https://docs.python.org/3/library/__main__.html
>
>
> chri
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subjectUnsubscribe
>


Re: binding free symbols in a lambda definition

2017-02-08 Thread Alexander Burger
On Wed, Feb 08, 2017 at 01:57:22PM +0100, pd wrote:
> *I feel* curry to be a unfortunate name for that function because I expect
> curry to be a function that once applied to another function with n
> parameters it returns a chain of applying functions with exactly one
> argument, that is having:
> 
> : (de sum (x y) (+ x y))
> 
> I expect a function named curry to behave this way:
> 
> (curry 'sum) -> ((x) '((y) (+ x y)))# it is really pseudocode not
> actually picolisp code since returning a lambda quoted this way won't do
> the job
> 
> or in classical lisp notation:
> 
> (curry 'sum) -> (lambda (x) (lambda (y) (+ x y)))
> 
> in a way you now can apply the curryfied sum partially:   ((curry 'sum) 2)
> -> ((y) (+ 2 y))  or  totally:  ((curry 'sum) 3 4) -> 7
> 
> But picolisp curry function doesn't do that, it simply returns a lambda


You can easily use PicoLisp's 'curry' to built the classical curry

   (de classiCurry (Fun)
  (let Par (list (caar Fun))
 (list Par
(cons 'curry Par (cdar Fun) (cdr Fun)) ) ) )


For your example (I use 'add' instead of 'sum' because the latter is built-in):

   : (de add (X Y) (+ X Y))
   -> add

   : (classiCurry add)
   -> ((X) (curry (X) (Y) (+ X Y)))

   : ((classiCurry add) 2)
   -> ((Y) (job '((X . 2)) (+ X Y))


If you know that your function does not modify the values of its parameters, you
can use pattern variables to get more efficient code with constants and no need
for a 'job' closure:

   : (de add (@X Y) (+ @X Y))
   -> add

   : (classiCurry add)
   -> ((@X) (curry (@X) (Y) (+ @X Y)))

   : ((classiCurry add) 2)
   -> ((Y) (+ 2 Y))

In both cases you get:

   : (((classiCurry add) 2) 3)
   -> 5

♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: binding free symbols in a lambda definition

2017-02-08 Thread Erik Gustafson
But picolisp curry function doesn't do that, it simply returns a lambda
with 1 parameter having the other one properly substituted with its value
thus making impossible to partially apply the returned function


I still think 'curry' is what you want.


Note that 'curry' works with an arbitrary number of parameters, e.g.

   (curry (@X @Y @Z) ... )

As far as partial application, wasn't 'adder' an example of that?

   : (adder 3)
   -> ((X) (+ X 3))  # partial application
   : ((adder 3) 7)   # used as function call
   -> 10

I'm not sure that a structure such as

   ((X) '((Y) (+ X Y)))

would be very useful in PL, though it could certainly be built with our
friends 'fill' or 'macro'. But I'm also not sure I understood your question
entirely.

What that helpful at all?


Re: unit testing?

2017-02-08 Thread Christophe Gragnic
On Wed, Feb 8, 2017 at 12:13 PM, Alexander Burger  wrote:
>> I'm thinking of Python's `if __name__ == '__main__' and Perl's unless
>> (caller) {...}
>
> I don't know Python and Perl well enough. But perhaps 'once' is what you think
> of?
>
>(once (load "xxx.l"))

No, it's different.

In Python there's a «magic» variable named __name__.
As files can be:
- imported from another script/module
- interpreted directly from top leve
it provides a trick to distinguish between those two ways to use a
script/module.
See here:
https://docs.python.org/3/library/__main__.html


chri
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: binding free symbols in a lambda definition

2017-02-08 Thread Erik Gustafson
Hi,

If I understand correctly what you said the reason for  (let K 3 '(print
`K)) returning (print NIL)  rather than (print 3)  [being K not previously
defined]  is that the sequence of steps is:


Almost, there is a slight confusion in step 2. I would revise it like so:

1- read the whole let expression , here (let K 3 '(print `K))


2- reader encounters `K, thus K is evaluated (returns NIL) immediately, and
that result is substituted into the original expression before any runtime
evaluation takes place. So now the expression is (let K 3 '(print NIL)).

3- evaluate the "let prog" in the context stated by let bindings, thus
evaluates '(print NIL) in a context where K is bound to 3, but obviously K
is not used in the "let prog"



if so, would be hard to make the jump over step 2? that is making the quote
protecting the whole expression and evaluating the read-macro ` only in
step 3 when the expression is evaluated under symbol bindings stablished by
let?maybe I'm saying nosense, sorry in advance! ;-)


This issue here is readtime vs runtime. The read-macros will not be able to
access symbol bindings created at runtime. You will need to use 'fill' or
'macro' for this.

   : (let K 3 (fill '(print K) 'K))
   -> (print 3)
   # or
   : (let @K 3 (macro '(print @K)))
   -> (print 3)

This article discusses the subtleties of the process in more detail:

http://picolisp.com/wiki/?readvsruntime

Happy hacking,
Erik


Re: Mips / LibreCMC build

2017-02-08 Thread Mike Pechkin
On Wed, Feb 8, 2017 at 3:45 PM, Christopher Howard <
christopher.how...@qlfiles.net> wrote:

> I would like to share the build with the world. Did you
> guys want to host the build somehow, or did you want me to host
> elsewhere and then link to my repo?


​You could​
​ create page on
http://picolisp.com/wiki
with anounce here and or reddit.com/r/lisp

​Mike
​


Re: binding free symbols in a lambda definition

2017-02-08 Thread Lindsay John Lawrence
And then there's this... (From "Lisp 1.5 Programmer's Manual".. McCarthy...
)...

# This function gives the result of substituting the S-expression
# x for all occurrences of the atomic symbol y in the S-expression z.
(de subst (X Y Z)
   (cond
  ((= Y Z) X)
  ((atom Z) Z)
  (T (cons (subst X Y (car Z)) (subst X Y (cdr Z ) )

which lets you write things like

: (de myf (N) (subst N 'N '((x) (+ x N
-> myf
: (myf 1)
-> ((x) (+ x 1))
: ((myf 1) 99)
-> 100
: (myf '(* 3 33))
-> ((x) (+ x (* 3 33)))
: ((myf '(* 3 33)) 1)
-> 100

You could build that out... picolisp ... (= code data)
but at the end of the day you would probably end up  with 'curry'. (
http://software-lab.de/doc/faq.html#closures)..  with a job environment to
manage scope, etc

/Lindsay

But I feel more comfortable with the other you provided
>
> : (de adder (N) (list '(x) (list '+ 'x (eval 'N
>
> because I feel more in control of generated lambda
>
> thanks!
>


Re: Modularization / Shared Libraries

2017-02-08 Thread Mike Pechkin
On Wed, Feb 8, 2017 at 3:20 PM, Christopher Howard <
christopher.how...@qlfiles.net> wrote:

> Hi all, picolisp newbie here. I was trying to figure out how to
> "modularize" my code; there doesn't seem to be a module system built in,
> but the reference doc did mention support for shared libraries. A few
> questions:
>

​As I can understand you mix two different functions - load and native



>
> 1) On Gnu/Linux, how do you put code into a shared library?
>
>
​Look how builtin tests splits to files:​
https://bitbucket.org/mmamkin/picolisp/src/e33e90fb0e11aa6cdb8634c8ef73b1dac5c1f60a/lib/test.l?at=default=file-view-default



> 2) Where on the system does picolisp search for shared libraries?
>

native searches in dirs from ldconfig -p​


Mips / LibreCMC build

2017-02-08 Thread Christopher Howard
Hi all, I was able to compile picolisp for mips32r2 to run on
librecmc-1.3.4, which I did for the purpose of having a lisp interpreter
on my TPE-R1100. I would like to share the build with the world. Did you
guys want to host the build somehow, or did you want me to host
elsewhere and then link to my repo? I was planning on doing a new build
for each release of librecmc, if it proves necessary.

This build was a little more complicated than a regular one, as it is a
buildroot-based embedded environment, and the embedded environment does
not have it's own compiler. So I had to (1) build a compilation toolkit
from the librecmc source code; (2) put the picolisp source code inside
the toolkit; (3) modify the Makefile to compile with the correct flags,
and to use the toolkit compiler; (4) deleted src/ and doc/ files to get
a build slim enough to fit on the limited embedded memory; (5) tarballed
it and installed onto the librecmc system just following the "global
installation" instructions. Seems to work great. (I used it to write
some code to turn the TPE-R1100 LEDs into a binary clock display.)

I have not yet created a proper buildroot package as that looked like it
was going to be more complicated.

-- 
https://qlfiles.net
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Modularization / Shared Libraries

2017-02-08 Thread Christopher Howard
Hi all, picolisp newbie here. I was trying to figure out how to
"modularize" my code; there doesn't seem to be a module system built in,
but the reference doc did mention support for shared libraries. A few
questions:

1) On Gnu/Linux, how do you put code into a shared library?

2) Where on the system does picolisp search for shared libraries?

-- 
https://qlfiles.net
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: binding free symbols in a lambda definition

2017-02-08 Thread pd
Hi Alex

> The key there is the back-quote (`) before the L to force evaluation
> > See the doc section on 'Read-Macros'
> > http://software-lab.de/doc/ref.html#macro-io
>
> Exactly. So the whole 'let' expression is read, *then* evaluated. 'L' is
> what it
> was globally at the time this expression was read, usually NIL.
>
>
If I understand correctly what you said the reason for  (let K 3 '(print
`K)) returning (print NIL)  rather than (print 3)  [being K not previously
defined]  is that the sequence of steps is:

1- read the whole let expression , here (let K 3 '(print `K))
2- evaluate the whole let expression resulting in  (let K 3 '(print NIL))
since the evaluation of K returns NIL in this context because K is not
defined
3- evaluate the "let prog" in the context stated by let bindings, thus
evaluates '(print NIL) in a context where K is bound to 3, but obviously K
is not used in the "let prog"

is it that way?

if so, would be hard to make the jump over step 2? that is making the quote
protecting the whole expression and evaluating the read-macro ` only in
step 3 when the expression is evaluated under symbol bindings stablished by
let?maybe I'm saying nosense, sorry in advance! ;-)


Re: binding free symbols in a lambda definition

2017-02-08 Thread pd
On Wed, Feb 8, 2017 at 5:37 AM, Erik Gustafson 
wrote:

> I think 'curry' is what you're looking for. Your 'adder' example could be
> written as:
>
>: (de adder (@N) (curry (@N) (X) (+ X @N)))
>-> adder
>: (adder 3)
>-> ((X) (+ X 3))
>: (doc 'curry)  # for more info  :)
>
> Hope that helps,
> Erik
>
>
this does the job and is exactly what I was looking for  (together with the
fill solution pointed afterwards)  but I feel uncomfortable with the use of
curry here due to my functional programming background...

*I feel* curry to be a unfortunate name for that function because I expect
curry to be a function that once applied to another function with n
parameters it returns a chain of applying functions with exactly one
argument, that is having:

: (de sum (x y) (+ x y))

I expect a function named curry to behave this way:

(curry 'sum) -> ((x) '((y) (+ x y)))# it is really pseudocode not
actually picolisp code since returning a lambda quoted this way won't do
the job

or in classical lisp notation:

(curry 'sum) -> (lambda (x) (lambda (y) (+ x y)))

in a way you now can apply the curryfied sum partially:   ((curry 'sum) 2)
-> ((y) (+ 2 y))  or  totally:  ((curry 'sum) 3 4) -> 7

But picolisp curry function doesn't do that, it simply returns a lambda
with 1 parameter having the other one properly substituted with its value
thus making impossible to partially apply the returned function

Is there anyway in picolisp to reproduce the functional curry behaviour?
that's a sequence of lambdas allowing partial application


Re: binding free symbols in a lambda definition

2017-02-08 Thread pd
On Wed, Feb 8, 2017 at 7:15 AM, Lindsay John Lawrence <
lawrence.lindsayj...@gmail.com> wrote:

> 'fill' (http://software-lab.de/doc/refF.html#fill) does the job in some
> cases as well and is a bit easier to read...
>
> : (de adder (N) (let @X N (fill '((x) (+ x @X)
> -> adder
>
>
this is a solution very similar to newlisp style, and probably  fill  is
the most similar function to newlisp's  expand (and curry being the second
most similar ;)

But I feel more comfortable with the other you provided

: (de adder (N) (list '(x) (list '+ 'x (eval 'N

because I feel more in control of generated lambda

thanks!


Re: binding free symbols in a lambda definition

2017-02-08 Thread Lindsay John Lawrence
Alex,

My mistake! In playing with that code,  I had defined (setq L 99) shortly
before that and forgotten I had done so.
Without that, as you pointed out

: (de myf (F L) (F L))
-> myf
: (let (L 99) (myf '((x) (+ (car x) `L)) (1 2)))
-> NIL

A good lesson in taking care with scope and current execution environment.

Thanks!
/Lindsay




On Tue, Feb 7, 2017 at 11:34 PM, Alexander Burger 
wrote:

> Hi Lindsay,
>
> > :(de myf (F L) (F L))
> > -> myf
> > : (let (L 99) (myf '((x) (+ (car x) `L)) (1 2)))
> > -> 100
>
> I do not think this works.
>
>
> > The key there is the back-quote (`) before the L to force evaluation
> > See the doc section on 'Read-Macros'
> > http://software-lab.de/doc/ref.html#macro-io
>
> Exactly. So the whole 'let' expression is read, *then* evaluated. 'L' is
> what it
> was globally at the time this expression was read, usually NIL.
>
>
> As Erik said, 'curry' is a way:
>
>: (let (L 99) (myf (curry (L) (X) (+ (car X) L)) (1 2)))
>-> 100
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: unit testing?

2017-02-08 Thread Alexander Burger
On Wed, Feb 08, 2017 at 09:52:58AM +, dean wrote:
> When developing non-trivial functions in isolationyou need to copy some
> of the supporting scaffolding over from your main program to support it.
> When you subsequently come to "load" the module into your main
> program...there's a danger of duplicate scaffolding.

This is normally not a problem. Typical soure files are written in such a way
that you can re'load' them any time, and as often as you want. PicoLisp loads
files extremely fast.

In fact this is the normal way of interactive development.


> Is there some way to hide the copied scaffolding in your module along with
> the module's main clause upon loading

"Hide"?


> or perhaps with the flick of a "switch".
> I'm thinking of Python's `if __name__ == '__main__' and Perl's unless
> (caller) {...}

I don't know Python and Perl well enough. But perhaps 'once' is what you think
of?

   (once (load "xxx.l"))

However, this disables the above development style. Same goes for any other
similar method, e.g.

   (unless foo  # 'foo' is defined in "foo.l"
  (load "foo.l") )

or

   `(not foo)  # Abort loading this file if 'foo' is defined
   (de foo ()  # Otherwise go ahead and define stuff
  ... )

♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: A script that concatenates ref. and tutorial files into one file

2017-02-08 Thread Jon Kleiser
Hi Alex,

Thanks for pointing out why I should use ‘use’ on those symbols. I have now 
updated my project.

/Jon

> On 7. Feb, 2017, at 17:36, Alexander Burger  wrote:
> 
> Hi Jon,
> 
>> I have noticed that frequent use of ‘setq’ has been questioned recently on
>> this list. In my convConcat.l script there are quite a few setq’s that 
>> possibly
>> could have been coded in a better way. Let me know if you spot some obvious
>> candidates.
> 
> Basically there is nothing bad about 'setq'.
> 
> It is just problematic if you use it to modify not-locally-bound symbols (the
> term is "free variables") without them being clearly meant as global variables
> (by convention with a leading '*'), or from functions meant as local to other
> functions (by convention with a leading '_').
> 
> 'lint' should complain in such cases.
> 
> In case of convConcat.l, you set some globals in the beginning, and local
> variables like 'Head', 'Tail', 'Val' and 'C'. Looks all good.
> 
> 
> If I lint the code, I just get a single warning
> 
>   : (lintAll)
>   -> ((convLink (bnd @Props @After @X @Before)))
> 
> which means "please bind these four symbols" in function 'convLink'.
> 
> This is because 'match' also sets values. You can fix this by calling 'use' on
> them:
> 
>   (de convLink (F Chunk)
>  # First checking special case 
>  (use (@Props @After @X @Before)
> (if (match '(@Before < a " " n a m e = "\"" > @X "\"" > @After) Chunk)
> 
> ♪♫ Alex
> -- 



unit testing?

2017-02-08 Thread dean
When developing non-trivial functions in isolationyou need to copy some
of the supporting scaffolding over from your main program to support it.
When you subsequently come to "load" the module into your main
program...there's a danger of duplicate scaffolding.
Is there some way to hide the copied scaffolding in your module along with
the module's main clause upon loading
or perhaps with the flick of a "switch".
I'm thinking of Python's `if __name__ == '__main__' and Perl's unless
(caller) {...}
Just wondering.


Appimage.org

2017-02-08 Thread Jakob Eriksson
Could someone check out http://appimage.org ?

It seems to gain momentum now and PicoLisp in that format would make it really 
easy to use.


Best regards,
Jakob
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Future of PicoLisp?

2017-02-08 Thread Henrik Sarvell
How convenient then that compiling PL is trivial, it's probably the easiest
and most hassle free thing I've ever had to compile from source.

On Fri, Feb 3, 2017 at 8:47 AM, Alexander Burger 
wrote:

> Hi all,
>
> the future of PicoLisp is dark. I'm not sure if it can survive in packaged
> distribution.
>
> Ubuntu doesn't support it any more, probably due to the PIE (position
> independent executable) on x86-64.
>
> And at least on Android they seem to demand switching to Clang. The 32-bit
> versions of PicoLisp (pil32 and mini) which are written in C cannot be
> compiled
> on Clang, because Clang doesn't support dynamically allocated arrays, which
> pil32 depends on. As far as I notices, pil64 also has trouble on
> Clang/Android.
>
> :( Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>