Re: Is there a mechanism to save the last defined function?

2021-04-19 Thread Alexander Burger
On Tue, Apr 20, 2021 at 07:30:50AM +0200, Davide BERTOLOTTO wrote:
> I don't know of any *Function global, but hey, it's lisp ;) you can do your
> own 'de' like this, with a docstring clojure-style (after args)
> 
> (de de+ Rest
>   (let ((@Name @Args Doc . @Body) Rest)  (macro (de @Name
> @Args ~'@Body)) (put @Name 'Doc Doc)
>  Name))

Right. 'de+' is even better than redefining 'de' (and easier), as it indicates
the changed behavior.

☺/ A!ex

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


Subscribe

2021-04-19 Thread Radek Svoboda



Re: Is there a mechanism to save the last defined function?

2021-04-19 Thread Davide BERTOLOTTO
Sorry for the weird formatting:
(de de+ Rest
  (let ((@Name @Args Doc . @Body) Rest)
  (macro (de @Name @Args ~'@Body))
  (put @Name 'Doc Doc)
  @Name)) # there was a typo in my previous post

Then you can do:
(de+ f (A)
  "docstring"
  A)

Otherwise just after the function declaration you can do
(put 'f 'docstr "docstring")


On Tue, Apr 20, 2021, 07:30 Davide BERTOLOTTO 
wrote:

> I don't know of any *Function global, but hey, it's lisp ;) you can do
> your own 'de' like this, with a docstring clojure-style (after args)
>
> (de de+ Rest
>   (let ((@Name @Args Doc . @Body) Rest)  (macro (de @Name
> @Args ~'@Body)) (put @Name 'Doc Doc)
>  Name))
>
> Maybe Alex has something more to add
>
> Regards,
> Davide
>
> On Tue, Apr 20, 2021, 04:45 polifemo  wrote:
>
>> Inspired by the way methods are defined, by just defining them and
>> looking which class a method belongs to by looking into the global variable
>> *Class, I'd like to have a similar mechanism for creating docstrings.
>>
>> My idea is something like this:
>> ```
>> (de f (A) A)
>> (mkdocstr "A test function that returns its argument evaluated")
>> ```
>>
>> where mkdocstr is defined like this:
>> ```
>> (de mkdocstr (Docstr)
>>(put *Function 'docstr Docstr) )
>> ```
>>
>> This, of course, requires some global variable *Function that saves the
>> last symbol defined by 'de. Is there such a variable? Or is there a way to
>> change 'de to write to that variable?
>>
>


Re: Is there a mechanism to save the last defined function?

2021-04-19 Thread Alexander Burger
On Mon, Apr 19, 2021 at 09:37:52PM -0500, polifemo wrote:
> This, of course, requires some global variable *Function that saves the
> last symbol defined by 'de. Is there such a variable? Or is there a way to
> change 'de to write to that variable?

Yes. It is a bit tricky because 'de' must be redefined (with 'def')
while it is used.

Directly using (de de ...) gives a "redefined" warning, so i would use 'undef'
first:

   : (private) Args

   : ((undef 'de) de Args
  (def
 (setq *Function (car Args))
 (cdr Args) ) )
   -> de

   : (pp 'de)
   (de de priv~Args
  (def (setq *Function (car priv~Args)) (cdr priv~Args)) )
   -> de

   : (de f (A) (inc A))
   -> f

   : (pp 'f)
   (de f (A)
  (inc A) )
   -> f

   : *Function
   -> f

☺/ A!ex

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


Re: Is there a mechanism to save the last defined function?

2021-04-19 Thread Davide BERTOLOTTO
I don't know of any *Function global, but hey, it's lisp ;) you can do your
own 'de' like this, with a docstring clojure-style (after args)

(de de+ Rest
  (let ((@Name @Args Doc . @Body) Rest)  (macro (de @Name
@Args ~'@Body)) (put @Name 'Doc Doc)
 Name))

Maybe Alex has something more to add

Regards,
Davide

On Tue, Apr 20, 2021, 04:45 polifemo  wrote:

> Inspired by the way methods are defined, by just defining them and looking
> which class a method belongs to by looking into the global variable *Class,
> I'd like to have a similar mechanism for creating docstrings.
>
> My idea is something like this:
> ```
> (de f (A) A)
> (mkdocstr "A test function that returns its argument evaluated")
> ```
>
> where mkdocstr is defined like this:
> ```
> (de mkdocstr (Docstr)
>(put *Function 'docstr Docstr) )
> ```
>
> This, of course, requires some global variable *Function that saves the
> last symbol defined by 'de. Is there such a variable? Or is there a way to
> change 'de to write to that variable?
>


Re: ^X does not exit a breakpoint in pil21

2021-04-19 Thread Alexander Burger
On Mon, Apr 19, 2021 at 07:41:37PM -0500, polifemo wrote:
> it seems that ^X does not exit a breaking point to the main picolisp
> process anymore.

This is correct. Because the command line input in pil21 is now via standard
readline(), it is no longer unter direct control.


> When I break a process with ^C, for example `(loop (println "hello world")
> (wait 1000))`, I enter a breakpoint, but I can't return to toplevel with ^X
> as I used to.

The way to abort input or to return to top level in general in now Ctrl-D.

Ctrl-D goes back to the top level, or - if already at top level - exits the
interpreter.

☺/ A!ex

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


Is there a mechanism to save the last defined function?

2021-04-19 Thread polifemo
Inspired by the way methods are defined, by just defining them and looking
which class a method belongs to by looking into the global variable *Class,
I'd like to have a similar mechanism for creating docstrings.

My idea is something like this:
```
(de f (A) A)
(mkdocstr "A test function that returns its argument evaluated")
```

where mkdocstr is defined like this:
```
(de mkdocstr (Docstr)
   (put *Function 'docstr Docstr) )
```

This, of course, requires some global variable *Function that saves the
last symbol defined by 'de. Is there such a variable? Or is there a way to
change 'de to write to that variable?


^X does not exit a breakpoint in pil21

2021-04-19 Thread polifemo
it seems that ^X does not exit a breaking point to the main picolisp
process anymore.

When I break a process with ^C, for example `(loop (println "hello world")
(wait 1000))`, I enter a breakpoint, but I can't return to toplevel with ^X
as I used to.

was this functionality disabled?

for now, I can write `(quit)` in the breakpoint prompt to go to toplevel,
though the lack of ^X caught me by surprise.


PilCon tomorrow

2021-04-19 Thread Alexander Burger
Hi all,

tomorrow the 20th we have the "late" PilCon again (16:00 UTC).

   https://meeting.itship.ch/PilCon

We can re-visit Vip for those who could not attend last time, and handle
possible further questions about Vip.

I can also report about a change in the 'stack' function, returning unused stack
sizes for running coroutines.

☺/ A!ex

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


Re: PilCon tomorrow (Anatomy of Vip)

2021-04-19 Thread Thorsten Jolitz
Hi Alex,
thanks for your effort here, I can follow your reasoning, emulating Emacs
produces a lot of commands , which is not exactly in the spirit of
simplicity, and one can just adapt it's workflow instead of adding more
commands.
But maybe I can reuse your code anyway!
Cheers Thorsten

Alexander Burger  schrieb am Mo., 19. Apr. 2021, 07:14:

> On Sun, Apr 18, 2021 at 07:13:50PM +0200, Alexander Burger wrote:
> > OK, thinking about it, I simplified it a little and will indeed use it
> > occasionally perhaps :)
> >
> >(de *F9  # Eval lines till mark "e"
> >   (evCmd
> >  (run (str (getText (jmpMark "e" ) )
> > ...
> > So now I do "me" somewhere to set ark "e" and then "F9" from somewhere
> before
> > that position to execute the code.
>
> No, thinking about it again, I will remove it frmm my ~/.pil/viprc :)
>
> It is useless, because
>
> 1. using the existing Ctrl-E on a few expressions, one after the other, is
> more
>interactive and intuitive than pressing many keys to select a region
> and then
>evaluate it with other keys.
>
> 2. it is easier to type ":l" to reload the whole file. In general I
> write
>sources to be 'load'able as a whole any time.
>
> 3. it wastes a precious function key.
>
> 4. it requires more rules to remember. Keep it simple!
>
> ☺/ A!ex
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>