Re: history not saved anymore?

2021-03-01 Thread Laurent Artaud

Le 01/03/2021 à 12:26, Alexander Burger a écrit :


I faintly remember to have seen this too, a long time ago.

Anybody else here with a better memory? I'm not sure at the moment, but is it
perhaps that (wait) does not work? What happens if you call

: (wait 200)

in non-debug mode? If so, it must depend on the OS.


Yep! This freezes pil64 on archlinux (pil21 works correctly)



Pil21 reads "~/.pil/rc" at startup. You could put the lines

(history
   (in "~/.pil/history"
  (make (while (line) (link @))) ) )

(push1 '*Bye '(out "~/.pil/history" (mapc prinl (history

into "~/.pil/rc". Instead of "~/.pil/history" you can use any other name (for
example, I keep separate histories per directory).



Thanks! It solves my problem!

Regards.

--
Laurent ARTAUD (laurent.art...@free.fr)

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



history not saved anymore?

2021-03-01 Thread Laurent Artaud

Hello.

I just switched to pil21 because I noticed a bug with pil64 in “pil +” and 
wanted to see if it was corrected… (when inserting a closing paren, the cursor 
jumps to the opening one and freezes)


I notice that the history is now limited to the beginning of the session…
“.pil/history” isn’t saved nor read anymore?

Regards.

--
Laurent ARTAUD


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


Re: PilCon tomorrow

2020-10-20 Thread Laurent Artaud

Le 20/10/2020 à 07:38, Alexander Burger a écrit :


I think there is no single video stream. PilCon is not a linear presentation
suitable for a youtube video. At least this is *my* impression. I use the
smartphone App to communicate, frequently switching manually between the views,
and a desktop browser for code and GUI. Nobody would want to watch this mess.



Maybe…

However, since the PilCon started, I noticed that the mailing list dried up…

I’m not an intensive PicoLisp user (I mainly use it instead of bash for 
scripting or for prototyping/proof of concept, though I haven’t coded much 
lately…) but I learned a lot from answers on the mailing list — and from some of 
the questions, too… :-)


I attended to most of the PilCon last Friday (anonymously and silently and it 
was mostly way over my head) for the first time, and I think that part of the 
questions transferred there.


In my opinion, replays could help those just wanting to learn/improve their 
coding skills simply because those are solutions to real life problems…


Though I agree that without at least a table of content — meaning more time 
spent on the thing — it wouldn’t be as useful: the ability to skip a subject one 
isn’t interested in is the big advantage I find to the list! :-)


Regards.

--
Laurent ARTAUD



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


Re: Stuck on function 'expDat' on PLEAC

2018-06-05 Thread Laurent Artaud

Le 05/06/2018 à 13:34, Alexander Burger a écrit :

Hi Arie,


(at least under Windows WSL) the function 'expDat' does not seem to work as
expected.

My results:
: (expDat "31")
-> NIL


We have June with only 30 days ;)
♪♫ Alex



It might be better to use "28" as an example in order for it to work any month 
of the year…


Regards.

--
Laurent ARTAUD (laurent.art...@free.fr)

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


problem with (rot) and (link)?

2012-11-05 Thread Laurent Artaud

I don't understand what is happening, here...

I am playing around with Problem 35 on Project Euler and just stumbled on this:


(de split-number (N)
   (mapcar format (chop (format N))) )


(de all-rotations (N)
   (let SN (split-number N)
  (make
 (for L (range 1 (length SN))
(link (rot SN))
(println SN) ) ) ) )

: (all-rotations 123)
(3 1 2)
(2 3 1)
(1 2 3)
- ((1 2 3) (1 2 3) (1 2 3))


I can't understand why I do not get the same result as the println.

Did I (yet again) miss-balance the parenthesis? If so, I can't see where...

Thanks.

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


Re: too many open files?

2012-09-06 Thread Laurent Artaud

Le 05/09/2012 19:20, Alexander Burger a écrit :

On Wed, Sep 05, 2012 at 09:34:10AM +0200, Alexander Burger wrote:

I don't have the time at the moment to investigate it further. I hope I
can fix it this evening.


We need just to insert a call to closedir(). I've uploaded a fix to the
code repository.

As I'm in the process of other changes, I don't want to provide a new
testing release at the moment. If you need a quick fix, please insert a
single line in src64/main.l and re-assemble the binary:

2922a2923
  cc closedir(Z)  # Close directory


I.e. the context is

   do
  cc readdir(Z)  # Find first directory entry
  null A  # OK?
  if z  # No
 cc closedir(Z)  # Close directory  -- NEW
10   ld E Nil  # Return NIL
 pop Z
 pop X
 ret
  end
  lea E (A D_NAME)  # Pointer to name entry
  cmp X Nil  # flg?
   while eq  # Yes

Cheers,
- Alex



Thanks for the quick fix!

--
Laurent ARTAUD (laurent.art...@free.fr)
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: too many open files?

2012-09-06 Thread Laurent Artaud

Le 06/09/2012 08:01, Alexander Burger a écrit :

Hi Laurent,

back to your original mail:


By the way, if anyone know what lib to use for (native) to make a
lstat syscall so I can replace the stat shell call, I'd be very
grateful: I can't find where it is! (contrary to what I thought, it
is NOT in libc...)


It seems the internal symbol is '__xstat'.


From /usr/include/x86_64-linux-gnu/sys/stat.h:


__extern_inline int
__NTH (stat (__const char *__path, struct stat *__statbuf))
{
  return __xstat (_STAT_VER, __path, __statbuf);
}

That's a pity, because it makes it rather unportable.




So... If I need more speed, I'll have to make a C lib calling lstat, then call 
this one with (native)... I think I'll stay with the shell call ;-)




BTW, instead of using 'line', 'split' and 'pack' in


(de stat (Path)
(mapcar pack
   (split
  (in
 (list stat -c %f %s %u %g %h %i %X %Y %Z Path)
 (line) )
) ) )


and later parsing it with 'hex' and 'format', you could read it
directly:

(in (list stat -c %f %s %u %g %h %i %X %Y %Z Path)
(make
   (link (hex (till  ))
   (do 8
  (link (read)) ) ) ) )



Thanks for this! I intended to replace the call to (multimap) when I discovered 
that I had only one (hex) to call...


Regards,
--
Laurent ARTAUD (laurent.art...@free.fr)
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


too many open files?

2012-09-04 Thread Laurent Artaud

I am using a coroutine as a generator to list the files from a sub-tree.
However, I got this when I attempted some timing tests:

$ pil +
: (load bug.l)
- nextFile
: (do 2 (while (nextFile /tmp NIL NIL)))
!? (in (list stat -c %f %s %u %g %h %i %X %Y %Z Path) (line))
Pipe error: Too many open files
? *NFCpt
- 4081
?
: (bye)
[/home/laurent/.pil/history:1] !? (out (pil history) (while (and New (n== New 
Hist0)) (prinl (pop 'New)) (dec 'N)) (setq Hist0 History) (do N (NIL Old) 
(prinl (pop 'Old

/home/laurent/.pil/history -- Open error: Too many open files
?

lsof | grep -i pil shows a lot of open files that should not be, since

(stat /tmp)

do not keep any file open after finishing.

Can anyone see what is the problem? (this is a partial code I used in an attempt 
to isolate the cause of the problem)


(setq
   S_IFDIR (hex 4000) #This is the file type constant of a directory file.
   S_IFLNK (hex a000) #This is the file type constant of a symbolic link.
   )

(de stat (Path)
   (mapcar pack
  (split
 (in
(list stat -c %f %s %u %g %h %i %X %Y %Z Path)
(line) )
   ) ) )

(de readlink (Path)
   NIL )

(de multimap (L1 L2)
   (make
  (while L1
 (link ((pop 'L1) (pop 'L2))) ) ) )

(setq *NFCpt 0)

(de nextFile (RootPath Exclusions Inclusions)
   (inc '*NFCpt)
   (co 'nextFile
  (let Dir RootPath
 (recur (Dir)
(for F (dir Dir)
   (let Path (pack Dir / F)
  # TODO: add here exclusion tests
  (setq Data
 (multimap # convert from string to integer
'(hex format format format format format format format 
format)

(stat Path) ) )
  (yield (append  # return (list Path lstat data for Path 
target if softlink NIL)

(list Path)
Data
(list
   (if (= S_IFLNK ( S_IFLNK (car Data)))
  (readlink Path)
  NIL ) ) ) )
  (if (= S_IFDIR ( S_IFDIR (car Data)))
 (recurse Path) ) ) ) ) ) ) )

By the way, if anyone know what lib to use for (native) to make a lstat syscall 
so I can replace the stat shell call, I'd be very grateful: I can't find where 
it is! (contrary to what I thought, it is NOT in libc...)


Thanks in advance.

Regards,
--
Laurent ARTAUD (laurent.art...@free.fr)
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: (native) wrapper around zlib

2012-08-23 Thread Laurent Artaud

Le 23/08/2012 08:57, Alexander Burger a écrit :

Hi Laurent,


It took the error message I got when I worked on the uncompress
function to realize that, indeed, InBuf should be a byte list, and
not a string... (this is binary data, and there are null bytes, and
a (pack (mapcar 'char TheList)) removes said bytes...)
Looking at the Memory Management section at
http://software-lab.de/doc/native.html, I am considering using
malloc (I will have many calls) but for what I have in mind, I would
need to be able to set and get the value of a malloc-ed variable
outside of a native call.
Is it possible?


Yes. This should be possible with 'struct'.



Thanks! It works perfectly!

Regards,
--
Laurent ARTAUD (laurent.art...@free.fr)
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Insertion time into the database seems to increase exponentially!

2012-07-31 Thread Laurent Artaud

Hello all!
As I like to do something useful when I learn a new language, I decided to do a 
backup system.

I obviously chose to use the integrated database engine to store the meta-data.
Unfortunately, the timings I get are starting to frighten me:

# Backup returns the number of +File insertions
# Before each run, I removed the database dir and exited pil, in order to ensure 
no interference.

: (bench (Backup /tmp/pico))
0.303 sec
- 322
: (bench (Backup /tmp/pico))
2.252 sec
- 644
: (bench (Backup /tmp/pico))
7.677 sec
- 966
: (bench (Backup /tmp/pico))
18.238 sec
- 1288
: (bench (Backup /tmp/pico))
35.535 sec
- 1610
: (bench (Backup /tmp/pico))
64.718 sec
- 1932
: (bench (Backup /tmp/pico))
107.136 sec
- 2254
: (bench (Backup /tmp/pico))
163.182 sec
- 2576
: (bench (Backup /tmp/pico))
227.789 sec
- 2898
: (bench (Backup /tmp/pico))
316.216 sec
- 3220

As you can see, given the progression, it will soon take more time to store the 
meta-data than processing the data itself.

Does anybody see if I made a mistake in my code?

(class +Chunk +Entity)
(rel cs (+Need +Number))  # checksum of this chunk
(rel files (+List +Joint) chunks (+File)) #

(class +File +Entity)
(rel pth (+Need +Ref +String))# file path
(rel size (+Need +Number))# file size
(rel accessTime (+Need +Number))  #
(rel modifyTime (+Need +Number))  #
(rel changeTime (+Need +Number))  #
(rel inode (+Need +Ref +Number))  #
(rel links (+Need +Number))   #
(rel uid (+Need +Number)) #
(rel gid (+Need +Number)) #
(rel accessRights (+Need +Number))#
(rel target (+String))# target of the softlink (if any)
(rel chunks (+List +Joint) files (+Chunk))# list of chunks (if any)
(rel backups (+List +Joint) files (+Backup))  #

(class +Backup +Entity)
(rel name (+Ref +String)) # name of this backup
(rel startDT (+Need +Ref +String))# start datetime of this backup 
(stamp T)
(rel endDT (+String)) # end datetime of this backup 
(empty if not finished)

(rel exclusions (+List +String))  # exclusion flags
(rel inclusions (+List +String))  # inclusion flags
(rel basePath (+Need +List +String))  # paths considered for this backup
(rel hostName (+Need +Ref +String))   # name of the host being backup'd
(rel files (+List +Joint) backups (+File))#

(dbs
   (0)
   (0 +Chunk)
   (0 +File)
   (0 (+File pth inode))
   (4 +Backup)
   (0 (+Backup name startDT hostName)) )
(let pa /tmp/test_db
   (ifn (info pa)  # if it does not already exists...
  (call 'mkdir pa) )   # create the path to store the DB
   (pool (pack pa /) *Dbs) ) # open the DB

# fake...
(de addFile (Bk P)
   (let o
  (request '(+File)
  'pth P
  'size 0
  'accessTime 1
  'modifyTime 2
  'changeTime 3
  'inode 4
  'links 1
  'uid 1001
  'gid 1002
  'accessRights 766 )
  (put!
 o
 'backups
 (append (; 'o backups) Bk) )
  o ) )

(de Backup (rootPath)
   (let obj1
  (request '(+Backup)
  'name (stamp)
  'startDT (stamp)
  'basePath rootPath
  'hostName (host localhost) )
  (put! *DB 'currentBackup obj1)
  # now, walk the path
  (let Dir rootPath
 (recur (Dir)
(for F (dir Dir)
   (let Path (pack Dir / F)
  (addFile obj1 Path)
  # note: change this test: it considers a link to a dir as a 
dir!
  (if (=T (car (info Path)))
 (recurse Path) ) ) ) ) )
  (length (get obj1 'files)) ) )


Thanks for your time.

Regards,
--
Laurent ARTAUD
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


suppression of the target for a +Joint do not update the +Joint

2012-07-26 Thread Laurent Artaud

Hello.

Here is a simplified test reproducing my problem:

(class +Content +Entity)
(rel data (+Number))
(rel containers (+List +Joint) contents (+Container))

(class +Container +Entity)
(rel data (+Number))
(rel contents (+List +Joint) containers (+Content))

(pool /tmp/test.db)

(setq objContainer
   (obj
  ((+Container))
  data 52 ) )
(commit)

(setq objContent
   (obj
  ((+Content))
  data 25 ) )
(commit)

(put!
   objContent
   'containers
   (append (; 'objContent containers) objContainer) )

(show objContent)
(show objContainer)

(zap objContainer)
(commit)
(show objContent)

A +Content can be linked to multiple +Container.
I was expecting to be able to remove the +Container and then, later, look for 
+Content with 'containers empty to remove them.

Obviously, my way does not work.


Please consider that I'm very new to picolisp (and to lisp more generally) so I 
may make basic mistakes.


Regards,
--
Laurent ARTAUD
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: PicoLisp Book

2012-07-21 Thread Laurent Artaud

Le 21/07/2012 20:05, Thorsten Jolitz a écrit :

Terry Palfrey terrypalfrey...@gmail.com
writes:

BTW
I just found out that there is an upper limit for book size (at
Amazon some 870 pages or so) in self-publishing, so if I include the
function reference (some 200 pages) and the rosettacode examples (huge),
what I really would like to do, there might be no other choice than
making it two books (i.e. there might be two different covers ;)




I fear that the price tag for a book this size would be outside of what I would 
pay for.
I would suggest that you consider PDF or ePub: it would both remove the maximum 
size limit and reduce your publication costs.


On a side note, I personally consider that a function reference MUST have a 
search engine, and as such, if you don't intend to expand on the online one 
(more examples, reasons for the use of one rather than the other in case of 
similar functionality, ...), then I don't think you should include the reference 
in a paper book.


Regards,

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


Subscribe

2012-07-14 Thread Laurent Artaud

Hello Laurent Artaud laurent.art...@free.fr :-)
You are now subscribed



--
Laurent ARTAUD (laurent.art...@free.fr)
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe