Re: Asyncronous IO

2008-10-10 Thread Alexander Burger
Hi Tomas,

 I attach a simple non-blocking echo server.  There are some functions

Nice!

 Conceptually it should not block, I am not sure how to test it though.
 Any ideas?

Positive testing works well:

   abu:~/pico ./p dbg.l nb-ex.l
   : (more *Run)
   (5 (when (accept @) (task @ Sock @ (callback Sock
   - NIL

second process

   abu:~/pico ./p dbg.l
   : (connect localhost )
   - 3
   : (out 3 (wr 1 2 3 254 255))
   - 255

first process

   callback 3 J=0 I=0 N=5
 read 5
 written 5
 rotate J=5 I=5 N=5
   end 3 J=0 I=0 N=5

   : *B 
   - (1 2 3 254 255)

   : (more *Run)
   (3 (job '((Sock . 3)) (callback Sock)))
   (5 (when (accept @) (task @ Sock @ (callback Sock
   - NIL

:-)

The difficult thing might be the negative test. Perhaps send a *lot* of
data, and do some ifconfig xxx down in between?



 - buffer could be local for the sockets, so 'callback' should be a
   closure...  I guess I would have to use 'job' but that's next lesson
   I have to look at:-)

There is already a closure for 'Sock'

   (task (port ) # Listen on port 
  (when (accept @)   # A connect arrived
 (task @ # Install another task on this socket
Sock @   # Keep the socket in the task's env
(callback Sock) ) ) )

resulted in (see above)

   (3 (job '((Sock . 3)) (callback Sock)))

Strictly speaking, the 'Sock' variable would not be necessary here,
because '@' is already bound to the file descritor when the task's body
is called. So a simple

   (task @ (callback @))

should also work. But you could put your buffer there:

   (task @
  Buffer (need 5)
  (callback @ Buffer) )

or similar.


 There should really be -m32 switch in the 'gcc' function.  It would

Thanks for the tip! I'll include it.


 also be useful if it would be possible optionally switch on -g without
 having to modify the gcc.l file.

I would use 'patch' in such a case:

   (patch gcc
  '(apply @A -o @Z)
  (append '(apply) @A '(-g -o) @Z) )

Cheers,
- Alex
-- 
UNSUBSCRIBE: mailto:[EMAIL PROTECTED]


Re: Asyncronous IO

2008-10-10 Thread Alexander Burger
Hi Konrad,

 But the underlying select function also provides non blocking writes.
 so that you can dely trying to write to a socket until it is ready for
 more data.

Yep, this is also needed.


 It would appear that task and *Run have no way of using this part of
 the select function.

Right. The syntax of *Run (positive file descriptors, negative timeouts)
does not allow such a specification. Internally, file descriptors for
writing are used, but currently only for interprocess pipes.

Cheers,
- Alex
-- 
UNSUBSCRIBE: mailto:[EMAIL PROTECTED]


Re: Asyncronous IO

2008-10-10 Thread Tomas Hlavaty
Hi Konrad,

 train. The task and *Run mechanism (if used with enough care) give us
 non blocking reads.

 But the underlying select function also provides non blocking writes.
 so that you can dely trying to write to a socket until it is ready for
 more data.

I would say that select (in C) and task and *Run (in picolisp) do not
have anything to do with blocking i/o.  It has to do something with
the concept of asynchronous.  In other words, when the process does
not have anything to do, it goes to sleep by calling select and when
there is some event on the registered file descriptors (e.g. read or
write is possible), the process is woken up.

Whether i/o is blocking or not is a property of the file/socket and
i/o functions.  So what gives you non-blocking reads and writes is
setting the file to non-blocking mode and then handling partial i/o
data in a specific way.

Cheers,

Tomas
-- 
UNSUBSCRIBE: mailto:[EMAIL PROTECTED]


Re: Asyncronous IO

2008-10-10 Thread Tomas Hlavaty
Hi Alex,

http://www.software-lab.de/refP.html#poll says:

   (poll 'cnt) - cnt | NIL

   Checks for the availability of data for reading on the file
   descriptor cnt. See also open, in and close.

   : (and (poll *Fd) (in @ (read)))  # Prevent blocking

The comment is a bit misleading as it does not prevent blocking
really.  The data might be available but the 'read' function might
still block.

Cheers,

Tomas
-- 
UNSUBSCRIBE: mailto:[EMAIL PROTECTED]


Re: Asyncronous IO

2008-10-10 Thread John Duncan
If the socket is set not to block, then the socket will read as much  
data as is available and the underlying read call will return the  
number of bytes read, right? So the poll will still be useful in an  
nbio world.

John

On 10 Oct 2008, at 12:36 PM, Alexander Burger wrote:

 Hi Tomas,

 The comment is a bit misleading as it does not prevent blocking
 really.  The data might be available but the 'read' function might
 still block.

 Yes, all those comments regarding non-blocking (also in the way Konrad
 used it) mean that during normal operations (i.e. not hanging in an
 error condition) everything will go smoothly. It does not mean
 non-blocking in the technical sense. But for those normal
 operations, it goes surprisingly well when messages observe the  
 PIPE_BUF
 limit. So the *application* is non-blocking, not the underlying
 protocol. Without *Run and (poll) the input would always block even  
 on a
 single input channel.

 Cheers,
 - Alex
 -- 
 UNSUBSCRIBE: mailto:[EMAIL PROTECTED]

-- 
UNSUBSCRIBE: mailto:[EMAIL PROTECTED]


Unsubscribe

2008-10-10 Thread Howard Gordon
Good bye Howard Gordon [EMAIL PROTECTED] :-(
You are now unsubscribed



-- 
UNSUBSCRIBE: mailto:[EMAIL PROTECTED]


Re: picoWiki

2008-10-10 Thread Tomas Hlavaty
Hi Henrik,

 I could help with implementing the code highlighting I have on
 prodevtips, it's all happening in the client through javascript, very
 easy actually, you simply need the ability to add html in the content,
 if the necessary javascript files are included then you can do:

 code=classpico
 /code

 And all pico lisp code in the code block will be highlighted.

nice, I did not notice the syntax highliting feature though as I have
javascript turned off.

Syntax highlighting is nice but I think the links to picolisp
reference manual are the most important part of the lisp markup.
That's the main power of the web I think, not having to look things up
but simply click on them... instant information.

If you fancy doing this in picoLisp (that's the thing we are after
here anyway;-), there are a few things that could be improved in the
current lisp tag in picoWiki:

1) highlight class names and link them to a reference explanation.  As
there is no single reference place similar to built in functions,
maybe create a picoWiki reference for classes and link it there,
i.e. create a page classes, list there classes similar to the
reference for functions and refer markup there.  (I will have to
implement some picoWiki markup for html anchor for this.)

2) highlight strings and persistent symbols

3) cute parenthesis highliting as in lisp paste would be nice, see
http://paste.lisp.org/display/68251 for example

4) the content of the lisp element can start with prompt, e.g. 

  : (setq lambda quote)
  - 67293272

the : and - are currently linked to the picolisp reference which
should not be the case.

I attach the file which generates the picolisp xref/highliting.  To
use it:

: (load '@lib/http.l)
- http404
: (load '@lib/xhtml.l)
- reset
: (load /tmp/markupLisp.l)
- markupLisp
: (markupLisp (setq lambda quote))
(a href=http://www.software-lab.de/refS.html#setq;setq/a lambda a 
href=http://www.software-lab.de/refQ.html#quote;quote/a)- T
: 

The markupLisp function gets a string and outputs html.

I hope to post the whole picoWiki code at some point when it's more
complete and the mess cleaned up bit:-)

Cheers,

Tomas

(setq *Xref
   (mapcar pack '(new  sym  str  char  name  sp?  pat?  fun?  all  intern  
extern    loc  box?  str?  ext?  touch  zap  length  size  format  chop  
pack  glue  pad  align  center  text  wrap  pre?  sub?  low?  upp?  lowc  uppc  
fold  val  getd  set  setq  def  de  dm  recur  undef  redef  daemon  patch  
xchg  on  off  onOff  zero  one  default  expr  subr  let  let?  use  accu  
push  push1  pop  cut  del  queue  fifo  idx  lup  cache  locale  dirname 
put get prop ; =: : :: putl getl wipe meta 
atom pair lst? num? sym? flg? sp? pat? fun? box? str? ext? bool not == n== 
=  =0 =T n0 nT  =  = match 
+ - * / % */ ** inc dec  lt0 ge0 gt0 abs bit?  | x| sqrt seed rand max 
min length size accu format pad oct hex fmt64 money 
car cdr caar cadr cdar cddr caaar caadr cadar caddr cdaar cdadr cddar cdddr 
cadddr cr nth con cons conc circ rot list need full make made chain link 
yoke copy mix append delete delq replace insert remove place strip split 
reverse flip trim clip head tail stem fin last member memq mmeq sect diff index 
offset assoc asoq rank sort uniq group length size val set xchg push push1 pop 
cut queue fifo idx balance get fill apply 
load args next arg rest pass quote as pid lit eval run macro curry def de 
dm recur recurse undef box new type isa method meth send try super extra with 
bind job let let? use and or nand nor xor bool not nil t prog prog1 prog2 if 
if2 ifn when unless cond nond case state while until loop do at for catch throw 
finally ! e $ sys call tick ipid opid kill quit task fork pipe later timeout 
bye 
apply pass maps map mapc maplist mapcar mapcon mapcan filter seek find pick 
cnt sum maxi mini fish by 
path in ipid out opid pipe ctl any sym str load hear tell key poll peek 
char skip eol eof from till line format scl read print println printsp prin 
prinl msg space beep tab flush rewind rd pr wr rpc wait sync echo info file dir 
lines open close port listen accept host connect nagle udp rc pretty pp show 
view here prEval mail 
*Class class dm rel var var: new type isa method meth send try object 
extend super extra with This 
pool journal id seq lieu lock begin commit rollback mark free dbck rel dbs 
dbs+ db: fmt64 tree root fetch store count leaf minKey maxKey genKey useKey 
init step scan iter prune zapTree chkTree db aux collect 
be goal prove - unify ? 
pretty pp show loc debug vi ld trace lint lintAll fmt64 
argv opt gc raw alarm protect heap env up stk date time usec stamp dat$ 
$dat datSym datStr strDat expDat day week ultimo tim$ $tim telStr expTel locale 
allowed allow pwd cd chdir ctty info dir dirname call tick kill quit task fork 
pipe timeout mail test bye 
NIL *OS *DB T *Solo *PPid *Pid @ @@ @@@ This *Dbg *Zap *Scl *Class *Dbs 
*Run *Hup *Sig1 *Sig2 ^ *Err *Rst *Msg *Uni *Led 

Re: Cutting a circular list.

2008-10-10 Thread Henrik Sarvell
There has been some prior discussion on the list:
http://www.mail-archive.com/search?q=circular+listsl=picolisp%40software-lab.de

It might or might not be of help.

/Henrik
-- 
UNSUBSCRIBE: mailto:[EMAIL PROTECTED]