<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Jan 10, 2009, at 12:02 AM, Terje Norderhaug wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>On Jan 9, 2009, at 10:20 PM, Alexander Repenning wrote:<br><blockquote type="cite">On Jan 8, 2009, at 6:37 PM, Terje Norderhaug wrote:<br></blockquote><blockquote type="cite"><blockquote type="cite">On Jan 8, 2009, at 5:05 PM, Alexander Repenning wrote:<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">At least for the vector caveat we have a solution. The approach &nbsp;<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">taken<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">may sound a bit crazy. We are implementing vector constants with a<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">combination of Lisp readers and Universally Unique Identifiers.<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">Perhaps not super elegant, there is bound to be a better &nbsp;<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">solution, but<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">it works. &nbsp;Code at the end. A call to a vector function looks like<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">this<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">(glColor3fv {0.5 0.1 0.8})<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">which is pretty close to what students "know" from C. The only issue<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">is that getting the cached value is not that fast. The hash table<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">access it the bottleneck.<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">What about only looking up the value at compile time? As in:<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">(glColor3fv #.{0.5 0.1 0.8})<br></blockquote></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">I don't think the Lisp compiler could handle that because it would &nbsp;<br></blockquote><blockquote type="cite">try to dump a foreign &nbsp;pointer.<br></blockquote><br>You may get beyond that by defining a make-load-form for your &nbsp;<br>representation of the gl vectors.</div></blockquote><div><br></div><div>that is true. One problem is that I do not have my own class to for the foreign type. However, a foreign pointer is of the built in class macptr. A&nbsp;make-load-form could&nbsp;easily&nbsp;be written for that class for instance by dumping the pointer content as sequence of byes. When running the compiled code each time the a new pointer would be allocated and initialization would take place. This would be slow and a&nbsp;wicket&nbsp;memory leak.&nbsp;</div><div><br></div><div>When the C compiler sees an expression like</div><div><br></div><div>glColor3fv ({0.5 0.1 0.8})</div><div><br></div><div>it will put a 3 float vector constant into some static memory space, not the heap</div><div><br></div><div>This is simple is C but tricky in Lisp. The Lisp compiler does not&nbsp;provide&nbsp;a simple means to define a raw float vector constant that would end up in static space. To achieve some similar in Lisp</div><div><br></div>(glColor3fv {0.5 0.1 0.8}) will be expanded into:</div><div><br></div><div>(glColor3fv&nbsp;&nbsp;(GET-CACHED-VECTOR 78533C19-BA5D-481A-9C54-5690D0A0F25E 0.5 0.1 0.8))</div><div><br></div><div>the&nbsp;GET-CACHED-VECTOR uses a globally unique&nbsp;identifier, e.g.,&nbsp;&nbsp;78533C19-BA5D-481A-9C54-5690D0A0F25E to store and retrieve the 3 floats in a hash table. This way the foreign pointer get created and returned the first time&nbsp;glColor3fv is called. Every&nbsp;consecutive&nbsp;call will return the same, hash table cached value. The net result is essentially the same as in C, a vector&nbsp;constant.</div><div><br></div><div>Alex</div><div><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"></blockquote></blockquote></blockquote><div>&nbsp;</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><blockquote type="cite"><div><br><br>-- Terje Norderhaug<br><br>_______________________________________________<br>Openmcl-devel mailing list<br><a href="mailto:Openmcl-devel@clozure.com">Openmcl-devel@clozure.com</a><br>http://clozure.com/mailman/listinfo/openmcl-devel<br><br></div></blockquote></div><br><div apple-content-edited="true"> <span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">Prof. Alexander Repenning</font></p><p style="margin: 0.0px 0.0px 0.0px 0.0px"><br class="khtml-block-placeholder"></p><p style="margin: 0.0px 0.0px 0.0px 0.0px">University of Colorado</p><p style="margin: 0.0px 0.0px 0.0px 0.0px">Computer Science Department</p><p style="margin: 0.0px 0.0px 0.0px 0.0px">Boulder, CO 80309-430</p><p style="margin: 0.0px 0.0px 0.0px 0.0px"><br class="khtml-block-placeholder"></p><p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">vCard: <a href="http://www.cs.colorado.edu/~ralex/AlexanderRepenning.vcf">http://www.cs.colorado.edu/~ralex/AlexanderRepenning.vcf</a></font></p><br class="Apple-interchange-newline"></span></span></span></div></span> </div><br></body></html>