Lisp HUG Maillist Archive

Evaluation

Hi,

I wonder were can I find the setup or doc to change
the way the LW evaluate piece of code inside functions
as well the evaluation in comments.

Example:

(defun is-atom (l)
  "(is-atom '((-6 2) (-3 2) -8))"       ; I get "is-atom" function
name - I look for output
  (prog (out)
    loop
    (cond ((null l) (return out)))
    (setq out (cond ((atom l) t) ((atom (car l)) t) (t nil)))      ;
same problem
    (setq l (cond ((equal out t) nil) (t (cdr l))))
    (go loop)))

;(is-atom '((-6 2 (-3 2) -8) (5 -1 (6 1) -9 1))   - function name.

I am looking for similar use of evaluation like in MCL - evaluation on
every level.

Second question is how to start LW6 with Listener in Output mode and
not Listener.

System: Mac OSX 10.6.7, LW6.0.1

Best wishes,

Janusz Podrazik
MRAC Publishing


Re: Evaluation

Janusz Podrazik <info@mracpublishing.com> writes:

> I wonder were can I find the setup or doc to change
> the way the LW evaluate piece of code inside functions
> as well the evaluation in comments.

The rules of evaluation are given by the ANSI Common Lisp Standard,
of which a copy is the Common Lisp Hyperspec:


http://www.lispworks.com/documentation/HyperSpec/Front/index.htm
http://www.lispworks.com/documentation/HyperSpec/Body/03_a.htm


Comments are not evaluated.  
Documentation strings are not evaluated either.
Documentation strings may sometimes be recovered and processed (eg. by a
documentation generating and formating utility).


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.


Re: Evaluation

I may did not explain correctly.
This should explain.

In CLOZURE (or MCL)

(defun addup (x y)
  (+ x y))
=> ADDUP

(addup 1 1)
=> 2

;(addup 1 2)
=> 3


(+ 1
   (+ 1
      (+ 1 0)  ;=> 1
      )           ;=> 2
   )              ;=> 3

;(+ 1 0)    ;= 1


In LISPWORKS 6

(defun addup (x y)
  (+ x y))
=> ADDUP

(addup 1 1)
=> 2

;(addup 1 2)
=> 2

(+ 1
   (+ 1
      (+ 1 0)  ;=> 3
      )           ;=> 3
   )              ;=> 3

;(+ 1 0)    ;= 3

--
MRAC Publishing
Janusz Podrazik

On Tuesday, 7 June 2011 at 16:11, Pascal J. Bourguignon wrote:

Janusz Podrazik <info@mracpublishing.com> writes:

I wonder were can I find the setup or doc to change
the way the LW evaluate piece of code inside functions
as well the evaluation in comments.

The rules of evaluation are given by the ANSI Common Lisp Standard,
of which a copy is the Common Lisp Hyperspec:


http://www.lispworks.com/documentation/HyperSpec/Front/index.htm
http://www.lispworks.com/documentation/HyperSpec/Body/03_a.htm


Comments are not evaluated.
Documentation strings are not evaluated either.
Documentation strings may sometimes be recovered and processed (eg. by a
documentation generating and formating utility).


--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.

Re: Evaluation

Janusz Podrazik <info@mracpublishing.com> writes:

> I may did not explain correctly.
> This should explain.
>
> In CLOZURE (or MCL)
>
> (defun addup (x y)
>   (+ x y))
> => ADDUP
>
> (addup 1 1)
> => 2
>
> ;(addup 1 2)
> => 3
>
> (+ 1
>    (+ 1
>       (+ 1 0)  ;=> 1
>       )           ;=> 2
>    )              ;=> 3
>
> ;(+ 1 0)    ;= 1
>
> In LISPWORKS 6
>
> (defun addup (x y)
>   (+ x y))
> => ADDUP
>
> (addup 1 1)
> => 2
>
> ;(addup 1 2)
> => 2
>
> (+ 1
>    (+ 1
>       (+ 1 0)  ;=> 3
>       )           ;=> 3
>    )              ;=> 3
>
> ;(+ 1 0)    ;= 3

It doesn't explain anything.  If you could put some words on it, it'd go
better...

If you want to see intermediary results, you may use TRACE.
(Unfortunately, it doesn't work conformingly on CL functions, only
yours.  However, it's possible that Lispworks an/or CCL TRACE work on CL
functions too).


CL-USER> (trace +)
WARNING: TRACE: redefining function + in top-level, was defined in C
;; Tracing function +.
(+)
CL-USER> (+ 1 (+ 1 (+ 1 0)))
 1. Trace: (+ '1 '0)
 1. Trace: + ==> 1
 1. Trace: (+ '1 '1)
 1. Trace: + ==> 2
 1. Trace: (+ '1 '2)
 1. Trace: + ==> 3
3
CL-USER> (untrace +)
(+)
CL-USER> 



You may also use STEP to do it interactively.

CL-USER> (step (+ 1 (+ 1 (+ 1 0))))
step 1 --> (+ 1 (+ 1 (+ 1 0)))
C/Step 1 USER[2]> :s

step 2 --> 1
C/Step 2 USER[3]> :s

step 2 ==> value: 1
step 2 --> (+ 1 (+ 1 0))
C/Step 2 USER[4]> :s

step 3 --> 1
C/Step 3 USER[5]> :s

step 3 ==> value: 1
step 3 --> (+ 1 0)
C/Step 3 USER[6]> :s

step 4 --> 1
C/Step 4 USER[7]> :s

step 4 ==> value: 1
step 4 --> 0
C/Step 4 USER[8]> :s

step 4 ==> value: 0
step 3 ==> value: 1
step 2 ==> value: 2
step 1 ==> value: 3
3
CL-USER> 


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.


Re: Evaluation

Is about placing cursor next to variable or closing parenthesis insight sexpt and pressing RETURN.

(+ 1
(+ 1 1) 
)

placing cursor next to 1 the Listener should output 1
placing cursor after first closing parenthesis the Listener should output 2
placing cursor at the end of sexpr the Listener should output 3

in LW the Listener prints - in all the cases - 3

I can't find any instruction on how to change this in LW documentation.

--
MRAC Publishing
Janusz Podrazik

On Tuesday, 7 June 2011 at 17:30, Pascal J. Bourguignon wrote:

Janusz Podrazik <info@mracpublishing.com> writes:

I may did not explain correctly.
This should explain.

In CLOZURE (or MCL)

(defun addup (x y)
(+ x y))
=> ADDUP

(addup 1 1)
=> 2

;(addup 1 2)
=> 3

(+ 1
(+ 1
(+ 1 0) ;=> 1
) ;=> 2
) ;=> 3

;(+ 1 0) ;= 1

In LISPWORKS 6

(defun addup (x y)
(+ x y))
=> ADDUP

(addup 1 1)
=> 2

;(addup 1 2)
=> 2

(+ 1
(+ 1
(+ 1 0) ;=> 3
) ;=> 3
) ;=> 3

;(+ 1 0) ;= 3

It doesn't explain anything. If you could put some words on it, it'd go
better...

If you wannt to see intermediary results, you may use TRACE.
(Unfortunately, it doesn't work conformingly on CL functions, only
yours. However, it's possible that Lispworks an/or CCL TRACE work on CL
functions too).


CL-USER> (trace +)
WARNING: TRACE: redefining function + in top-level, was defined in C
;; Tracing function +.
(+)
CL-USER> (+ 1 (+ 1 (+ 1 0)))
1. Trace: (+ '1 '0)
1. Trace: + ==> 1
1. Trace: (+ '1 '1)
1. Trace: + ==> 2
1. Trace: (+ '1 '2)
1. Trace: + ==> 3
3
CL-USER> (untrace +)
(+)
CL-USER>



You may also use STEP to do it interactively.

CL-USER> (step (+ 1 (+ 1 (+ 1 0))))
step 1 --> (+ 1 (+ 1 (+ 1 0)))
C/Step 1 USER[2]> :s

step 2 --> 1
C/Step 2 USER[3]> :s

step 2 ==> value: 1
step 2 --> (+ 1 (+ 1 0))
C/Step 2 USER[4]> :s

step 3 --> 1
C/Step 3 USER[5]> :s

step 3 ==> value: 1
step 3 --> (+ 1 0)
C/Step 3 USER[6]> :s

step 4 --> 1
C/Step 4 USER[7]> :s

step 4 ==> value: 1
step 4 --> 0
C/Step 4 USER[8]> :s

step 4 ==> value: 0
step 3 ==> value: 1
step 2 ==> value: 2
step 1 ==> value: 3
3
CL-USER>


--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.

Re: Evaluation

Thanks, this is exactly what I am looking for but with out the selection, just the cursor and RETURN key.
I think this is most desirable functionality and I wonder why is not optional in LW.

I wonder if any one add already this functionality to there dev system.

best wishes,
--
MRAC Publishing
Janusz Podrazik

On Tuesday, 7 June 2011 at 20:05, Chris Perkins wrote:

I'm not sure if this is what you want.  You can select the text in the Listener and with the right click menu choose "Evaluate Region" and the selection (only) will be evaluated.  The result of the evaluation will typically appear in the Output pane.

Chris


On 6/7/11 2:24 PM, Janusz Podrazik wrote:
Is about placing cursor next to variable or closing parenthesis insight sexpt and pressing RETURN.

(+ 1
(+ 1 1) 
)

placing cursor next to 1 the Listener should output 1
placing cursor after first closing parenthesis the Listener should output 2
placing cursor at the end of sexpr the Listener should output 3

in LW the Listener prints - in all the cases - 3

I can't find any instruction on how to change this in LW documentation.

--
MRAC Publishing
Janusz Podrazik

On Tuesday, 7 June 2011 at 17:30, Pascal J. Bourguignon wrote:

Janusz Podrazik <info@mracpublishing.com> writes:

I may did not explain correctly.
This should explain.

In CLOZURE (or MCL)

(defun addup (x y)
(+ x y))
=> ADDUP

(addup 1 1)
=> 2

;(addup 1 2)
=> 3

(+ 1
(+ 1
(+ 1 0) ;=> 1
) ;=> 2
) ;=> 3

;(+ 1 0) ;= 1

In LISPWORKS 6

(defun addup (x y)
(+ x y))
=> ADDUP

(addup 1 1)
=> 2

;(addup 1 2)
=> 2

(+ 1
(+ 1
(+ 1 0) ;=> 3
) ;=> 3
) ;=> 3

;(+ 1 0) ;= 3

It doesn't explain anything. If you could put some words on it, it'd go
better...

If you wannt to see intermediary results, you may use TRACE.
(Unfortunately, it doesn't work conformingly on CL functions, only
yours. However, it's possible that Lispworks an/or CCL TRACE work on CL
functions too).


CL-USER> (trace +)
WARNING: TRACE: redefining function + in top-level, was defined in C
;; Tracing function +.
(+)
CL-USER> (+ 1 (+ 1 (+ 1 0)))
1. Trace: (+ '1 '0)
1. Trace: + ==> 1
1. Trace: (+ '1 '1)
1. Trace: + ==> 2
1. Trace: (+ '1 '2)
1. Trace: + ==> 3
3
CL-USER> (untrace +)
(+)
CL-USER>



You may also use STEP to do it interactively.

CL-USER> (step (+ 1 (+ 1 (+ 1 0))))
step 1 --> (+ 1 (+ 1 (+ 1 0)))
C/Step 1 USER[2]> :s

step 2 --> 1
C/Step 2 USER[3]> :s

step 2 ==> value: 1
step 2 --> (+ 1 (+ 1 0))
C/Step 2 USER[4]> :s

step 3 --> 1
C/Step 3 USER[5]> :s

step 3 ==> value: 1
step 3 --> (+ 1 0)
C/Step 3 USER[6]> :s

step 4 --> 1
C/Step 4 USER[7]> :s

step 4 ==> value: 1
step 4 --> 0
C/Step 4 USER[8]> :s

step 4 ==> value: 0
step 3 ==> value: 1
step 2 ==> value: 2
step 1 ==> value: 3
3
CL-USER>


--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.



Re: Evaluation

Thanks, It is close to the desired solution.
The option (Preferences) I use  - on Mac - is "Editor keys are like Mac OS X editors"
The output of the ^X^E (control-x control-e) is printed in command line in the editor window, not in the Listener Output.

--
MRAC Publishing
Janusz Podrazik

On Tuesday, 7 June 2011 at 20:54, Paul Tarvydas wrote:

Thanks, this is exactly what I am looking for but with out the selection, just the cursor and RETURN key.

Try "Evaluate Last Form", which is ^X^E in the emacs emulation mode. It evaluates the form directly to the left of the cursor.

pt

Re: Evaluation


On Jun 7, 2011, at 3:24 PM, Janusz Podrazik wrote:

> Thanks, It is close to the desired solution.
> The option (Preferences) I use  - on Mac - is "Editor keys are like Mac OS X editors"
> The output of the ^X^E (control-x control-e) is printed in command line in the editor window, not in the Listener Output.

Well you could do:

(editor:bind-key "Evaluate Last Form In Listener" #\control-\l :global :mac)

it doesn't need to be control-l, you can have the keyboard shortcut be anything you like.

Problem is, it creates a new listener window for every evaluation...

warmest regards,

Ralph


Raffael Cavallaro
raffaelcavallaro@me.com






Re: Evaluation


On Jun 8, 2011, at 12:36 PM, Brian Connoy wrote:

> 
> That sounds like buggy behaviour to me (or maybe there's a LW setting?).  On 
> LWW6, using "Evaluate Last Form in Listener" does not create a new Listener.

It is buggy, but I've found a workaround.

There should be a per-window reusability setting, available on LWM 6 through the menu Window:Customize:Reusable, but if set to Reusable, it is ignored, at least for the Listener for the purpose of Evaluate Last Form In Listener.

You need to set the global preference for Environment:Reuse all tools, then you don't get a new Listener for each invocation of Evaluate Last Form In Listener, and you can still get another Listener if you want one by unchecking Reusable in the Window:Customize menu for that Listener .

warmest regards,

Ralph


Raffael Cavallaro
raffaelcavallaro@me.com






Updated at: 2020-12-10 08:37 UTC