Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
another of those newbie question from a well known person
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  16 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Janos Blazi  
View profile  
 More options Dec 4 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: "Janos Blazi" <jbl...@netsurf.de>
Date: 1999/12/04
Subject: another of those newbie question from a well known person
This very stupid person is humbly asking for advice:

(1)
What is wrong with the following code:

(defun solve-eq-2x2 (eq1 eq2)
   (setq x (det2 (omit-elt eq1 2) (omit-elt eq2 2) ))
   (if (eql 0 x) nil (list (* -1 (/ (det2 (omit-elt eq1 0) (omit-elt eq2 0))
x))
                           (/ (det2 (omit-elt eq1 1) (omit-elt eq2 1)) x)
                     )
   )
)

When I load it into LispWorks I get a "syntactic warning for the form (setq
x (..." stating "X assumed special". The functions works fine (however ugly
it may be).

(2)
I would like to write a VERY SIMPLE macro v that is expanded to
  (subseq  g 3).
g is a list consisting of 6 elements. I found some fancy complicated
examples in the books but I cannot do this simple one.

Janos Blazi


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Robert Monfera  
View profile  
 More options Dec 4 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Robert Monfera <monf...@fisec.com>
Date: 1999/12/04
Subject: Re: another of those newbie question from a well known person

Janos Blazi wrote:
> (1)
> What is wrong with the following code:

> (defun solve-eq-2x2 (eq1 eq2)
>    (setq x (det2 (omit-elt eq1 2) (omit-elt eq2 2) ))
>    (if (eql 0 x) nil (list (* -1 (/ (det2 (omit-elt eq1 0) (omit-elt eq2 0))
> x))
>                            (/ (det2 (omit-elt eq1 1) (omit-elt eq2 1)) x)
>                      )
>    )
> )

If x is meant to be used locally, LET should be used in lieu of SETQ.

  (let ((x ...))
     [body] )

X will be accessible in body.

> (2)
> I would like to write a VERY SIMPLE macro v that is expanded to
>   (subseq  g 3).
> g is a list consisting of 6 elements. I found some fancy complicated
> examples in the books but I cannot do this simple one.

(defmacro foo (sequence start)
  `(subseq ,sequence ,start))

What is the benefit though?

If start is always 3:

(defmacro foo (sequence)
  `(subseq ,sequence 3))

But this also works:

(cddr g) or (nthcdr 3 g)

Robert


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Janos Blazi  
View profile  
 More options Dec 5 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: "Janos Blazi" <jbl...@netsurf.de>
Date: 1999/12/05
Subject: Re: another of those newbie question from a well known person

Robert Monfera <monf...@fisec.com> schrieb in im > > (2)

> > I would like to write a VERY SIMPLE macro v that is expanded to
> >   (subseq  g 3).
> > g is a list consisting of 6 elements. I found some fancy complicated
> > examples in the books but I cannot do this simple one.

> (defmacro foo (sequence start)
>   `(subseq ,sequence ,start))

> What is the benefit though?

Such a macro would make my code much more readable. But I did not express
exactly what I was going to do: I wanted to write a macro WITHOUT ANY
PARAMETERS like in C

  #define v (subseq g 3)

Is this possible?

Janos Blazi


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
H. Tunc Simsek  
View profile  
 More options Dec 5 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: "H. Tunc Simsek" <sim...@EECS.Berkeley.Edu>
Date: 1999/12/05
Subject: Re: another of those newbie question from a well known person
I would think that

(defmacro v ()
  `(subseq g 3))

is what you're looking for, but what is g, what should it be bound to?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Janos Blazi  
View profile  
 More options Dec 5 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: "Janos Blazi" <jbl...@netsurf.de>
Date: 1999/12/05
Subject: Re: another of those newbie question from a well known person
Thx, this was what I was looking for. Of course g is bound within a function
prior tu using the macro.

My only remaining problem is that these macros are global. Can I make them
local in some way, like in C

  #define v ...
     <body>
 #undefine v

?

Janos Blazi
H. Tunc Simsek <sim...@EECS.Berkeley.Edu> schrieb in im Newsbeitrag:
384A2BE6.F3535...@EECS.Berkeley.Edu...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Bradshaw  
View profile  
 More options Dec 5 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Tim Bradshaw <t...@tfeb.org>
Date: 1999/12/05
Subject: Re: another of those newbie question from a well known person

* Janos Blazi wrote:
> Such a macro would make my code much more readable. But I did not express
> exactly what I was going to do: I wanted to write a macro WITHOUT ANY
> PARAMETERS like in C
>   #define v (subseq g 3)
> Is this possible?

Yes.  DEFINE-SYMBOL-MACRO or SYMBOL-MACROLET.

--tim


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Bradshaw  
View profile  
 More options Dec 5 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Tim Bradshaw <t...@tfeb.org>
Date: 1999/12/05
Subject: Re: another of those newbie question from a well known person

* Janos Blazi wrote:
> Thx, this was what> My only remaining problem is that these macros are global. Can I make them
> local in some way, like in C
>   #define v ...
>      <body>
>  #undefine v

Typically you'd use SYMBOL-MACROLET for that:

        (symbol-macrolet ((x (+ 1 2))) x)

--tim


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Harley Davis  
View profile  
 More options Dec 6 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: "Harley Davis" <nospam_hda...@nospam.museprime.com>
Date: 1999/12/06
Subject: Re: another of those newbie question from a well known person
Janos Blazi <jbl...@netsurf.de> wrote in message

news:accompanist-82d7d1/INN-2.2.1/bodyguard@broadway.news.is-europe.net...

> > > I would like to write a VERY SIMPLE macro v that is expanded to
> > >   (subseq  g 3).

> > What is the benefit though?

> Such a macro would make my code much more readable. But I did not express
> exactly what I was going to do: I wanted to write a macro WITHOUT ANY
> PARAMETERS like in C

>   #define v (subseq g 3)

> Is this possible?

You can, but such a macro would not normally be considered by expert Lisp
programmers to make your code more readable - rather the opposite.

(Actually, that's true in C as well...)

-- Harley


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Erik Naggum  
View profile  
 More options Dec 6 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.no>
Date: 1999/12/06
Subject: Re: another of those newbie question from a well known person
* "Janos Blazi" <jbl...@netsurf.de>
| Such a macro would make my code much more readable. But I did not express
| exactly what I was going to do: I wanted to write a macro WITHOUT ANY
| PARAMETERS like in C
|
|   #define v (subseq g 3)
|
| Is this possible?

  yes, using symbol macros.  (it not smart to use them this way.)

#:Erik


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Erik Naggum  
View profile  
 More options Dec 6 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.no>
Date: 1999/12/06
Subject: Re: another of those newbie question from a well known person
* "Janos Blazi" <jbl...@netsurf.de>
| Such a macro would make my code much more readable. But I did not express
| exactly what I was going to do: I wanted to write a macro WITHOUT ANY
| PARAMETERS like in C
|
|   #define v (subseq g 3)
|
| Is this possible?

  yes, using symbol macros.  (it not smart to use them this way.)

#:Erik


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Janos Blazi  
View profile  
 More options Dec 6 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: "Janos Blazi" <jbl...@netsurf.de>
Date: 1999/12/06
Subject: Re: another of those newbie question from a well known person
Well, I have written a small library of routines that solve very simple
geometry problems, like calculating the intersection of hyperplanes in
3-space and the like. In this library a straight line in 3-space is
represented by a list g consisting of 6 elements.
Is g such a list then the line has the parametrization
   t -> (subseq g 0 3) + t*(subseq g 3)
that is the first three elements are the coordinates of a point on the
straight line and the second three elements are the direction.

Now it is very comfortable to think of the straight line as having the
paramtrization
  t->a-vec+t*v-vec
and this is why I would like to have those macros. After all, it is much
better to write (cross-prod v w) instead of
(cross-prod (subseq g 3) (subseq h 3).

BTW: THE CODE IS WORKING FINE AND IT WOULD HAVE TAKEN MORE TIME TO IMPLEMENT
RATIONAL ARITHMETIC IN C++ (THAT IS VERY IMPORTANT!) THAN WRITING THE WHOLE
500 LINES IN LISP, and then additionally as speed is not an issue it is
wonderful to work with the interpreter. It is like working in Maple V only
even more comfortable.
My geometric objects like striaght lines and points and planes are very
naturally represented by the lists in LISP and I decided not to use CLOS at
all.

Janos Blazi

H. Tunc Simsek <sim...@EECS.Berkeley.Edu> schrieb in im Newsbeitrag:
384A2BE6.F3535...@EECS.Berkeley.Edu...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Barry Margolin  
View profile  
 More options Dec 6 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Barry Margolin <bar...@bbnplanet.com>
Date: 1999/12/06
Subject: Re: another of those newbie question from a well known person
In article <amnesia-82h02q/INN-2.2.1/aroma...@broadway.news.is-europe.net>,

Janos Blazi <jbl...@netsurf.de> wrote:
>My geometric objects like striaght lines and points and planes are very
>naturally represented by the lists in LISP and I decided not to use CLOS at
>all.

Why not use DEFSTRUCT, though?

In any case, IMHO your use of global variables that are hard-coded into
macro expansions is very poor design.  If you want to avoid the overhead of
argument passing to functions, try declaring your functions INLINE.

--
Barry Margolin, bar...@bbnplanet.com
GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Marco Antoniotti  
View profile  
 More options Dec 7 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Marco Antoniotti <marc...@parades.rm.cnr.it>
Date: 1999/12/07
Subject: Re: another of those newbie question from a well known person

It would seem to me that your internal representation could be
improved (speed wise) by using structures or displaced arrays.

Cheers

--
Marco Antoniotti ===========================================
PARADES, Via San Pantaleo 66, I-00186 Rome, ITALY
tel. +39 - 06 68 10 03 17, fax. +39 - 06 68 80 79 26
http://www.parades.rm.cnr.it/~marcoxa


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeff Dalton  
View profile  
 More options Dec 7 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Jeff Dalton <j...@todday.aiai.ed.ac.uk>
Date: 1999/12/07
Subject: Re: another of those newbie question from a well known person

Barry Margolin <bar...@bbnplanet.com> writes:
> In any case, IMHO your use of global variables that are hard-coded into
> macro expansions is very poor design.  If you want to avoid the overhead of
> argument passing to functions, try declaring your functions INLINE.

That's good advice, but some implementations pretty much ignore
INLINE declarations.

What Common Lisps actually inline things?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pierre R. Mai  
View profile  
 More options Dec 7 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: p...@acm.org (Pierre R. Mai)
Date: 1999/12/07
Subject: Re: another of those newbie question from a well known person

Jeff Dalton <j...@todday.aiai.ed.ac.uk> writes:
> Barry Margolin <bar...@bbnplanet.com> writes:

> > In any case, IMHO your use of global variables that are hard-coded into
> > macro expansions is very poor design.  If you want to avoid the overhead of
> > argument passing to functions, try declaring your functions INLINE.

> That's good advice, but some implementations pretty much ignore
> INLINE declarations.

> What Common Lisps actually inline things?

CMU CL does inline user defined functions.

Regs, Pierre.

--
Pierre Mai <p...@acm.org>         PGP and GPG keys at your nearest Keyserver
  "One smaller motivation which, in part, stems from altruism is Microsoft-
   bashing." [Microsoft memo, see http://www.opensource.org/halloween1.html]


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kenneth P. Turvey  
View profile  
 More options Dec 7 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: kt-...@SprocketShop.com (Kenneth P. Turvey)
Date: 1999/12/07
Subject: Re: another of those newbie question from a well known person
On 07 Dec 1999 15:54:17 +0000,

Jeff Dalton <j...@todday.aiai.ed.ac.uk> wrote:
>Barry Margolin <bar...@bbnplanet.com> writes:

>> In any case, IMHO your use of global variables that are hard-coded into
>> macro expansions is very poor design.  If you want to avoid the overhead of
>> argument passing to functions, try declaring your functions INLINE.

>That's good advice, but some implementations pretty much ignore
>INLINE declarations.

>What Common Lisps actually inline things?

CMUCL seems to.

--
Kenneth P. Turvey <kt-...@SprocketShop.com>
--------------------------------------------
  We must all hang together, or most assuredly, we will all hang
  separately.
        -- Benjamin Franklin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »