Edit
Attach
Printable
topic end
<!-- * Set TOPICTITLE = #define private public - What's my vector, Victor? (08 Aug 2007) --> <style type="text/css"> pre {background-color:#ffeecc;} </style> %STARTINCLUDE% <a name="08"></a> ---+++ [[DefinePrivatePublic20070808][What's my vector, Victor?]] (08 Aug 2007) <summary> In graphics and CAD software, users occasionally have to enter 2D or 3D coordinates. One such application is <nop>CoCreate's [[http://www.cocreate.com/designer_modeling.cfm][<nop>OneSpace Modeling]] on which I [[http://www.clausbrod.de/myjob.html][work]] day to day to help me fill my fridge. </summary> To make coordinate entry as simple as possible, the implementation of Lisp which is embedded in the product understands the following vector syntax: <pre> (line :two_points 100,100 0,0) </pre> Common Lisp connoisseurs will notice that this is decidedly non-standard behavior. Those commas aren't supposed to be there; instead, commas serve their purpose in list quoting, particularly in macro definitions. (For a refresher, check out [[http://cl-cookbook.sourceforge.net/macros.html][The Common Lisp Cookbook - Macros and Backquote]].) And in any other implementation of Lisp, this code would indeed result in an error message such as "comma is illegal outside of backquote". <nop>OneSpace Modeling's embedded Lisp, however, will notice a pair of literal numbers and assume that what the user really meant to specify is a structure of type =gpnt2d=, which holds =x= and =y= slots for the coordinates. And so what is really evaluated is more like this: <pre> (line :two_points (oli:make-gpnt2d :x 100 :y 100) (oli:make-gpnt2d :x 0 :y 0)) </pre> =oli= is the Lisp package which exports the =gpnt2d= structure as well as its accessor and constructor functions. This explicit syntax is actually _required_ whenever you need to specify coordinates using non-literals, such as when the actual coordinates are the results of mathematical calculations. For instance, vector syntax is _not_ recognized in the following: <pre> (line :two_points (+ 50 50),100 0,0) </pre> Now you'll get the expected error message reporting that "a comma has appeared out of a backquote". To make this work, you'd have to say: <pre> (line :two_points (oli:make-gpnt2d :x (+ 50 50) :y 100) 0,0) </pre> But despite this limitation, the vector syntax extension was tremendously important for us: Coordinates can be entered in all kinds of places in the user interface where casual users would never suspect that what they are entering is actually thrown into funny engines which the propellerheads at <nop>CoCreate call "the Lisp reader" and "the Lisp evaluator". --- %STOPINCLUDE% %COMMENT{type="below" nonotify="on"}% ---
to top
End of topic
Skip to action links
|
Back to top
Edit
|
Attach image or document
|
Printable version
|
Raw text
|
Refresh
|
More topic actions
Revisions: | r1.5 |
>
|
r1.4
|
>
|
r1.3
|
Total page history
|
Backlinks
You are here:
Blog
>
DefinePrivatePublic20070808
r1.5 - 19 Sep 2007 - 21:51 -
ClausBrod
to top
Blog
This site
2017
:
12
-
11
-
10
2016
:
10
-
7
-
3
2015
:
11
-
10
-
9
-
4
-
1
2014
:
5
2013
:
9
-
8
-
7
-
6
-
5
2012
:
2
-
10
2011
:
1
-
8
-
9
-
10
-
12
2010
:
11
-
10
-
9
-
4
2009
:
11
-
9
-
8
-
7
-
6
-
5
-
4
-
3
2008
:
5
-
4
-
3
-
1
2007:
12
-
8
-
7
-
6
-
5
-
4
-
3
-
1
2006:
4
-
3
-
2
-
1
2005:
12
-
6
-
5
-
4
2004:
12
-
11
-
10
C++
CoCreate Modeling
COM & .NET
Java
Mac
Lisp
OpenSource
Scripting
Windows
Stuff
Changes
Index
Search
Maintenance
Impressum
Datenschutzerklärung
Home
Webs
Atari
Blog
Claus
CoCreateModeling
Klassentreffen
Main
Sandbox
Sommelier
TWiki
Xplm
Jump:
Copyright © 1999-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback