[Openmcl-devel] New (070408) OpenMCL snapshots available
gb at clozure.com
Tue Apr 10 05:50:57 UTC 2007
On Mon, 9 Apr 2007, Kevin Reid wrote:
> On Apr 9, 2007, at 2:54, Gary Byers wrote:
>> (#/initWithFrame: new-view (ns:ns-make-rect 100 100 200 200))
>> The rectangle above will -eventually- get reclaimed by the GC;
>> if you don't want to give the GC so much work to do, you might
>> prefer to do:
>> (ns:with-ns-rect (r 100 100 200 200)
>> (#/initWithFrame: new-view r))
> This seems like it ought to be automatically optimizable.
> Given that ns-make-rect is a function known to produce a GCable
> record and #/initWithFrame: is a function known not to store its
> arguments in the Lisp heap, said optimizer may be certain that the
> object will not necessarily be retained past the call, so
> deallocating it immediately after the call does not reduce its
> definite lifetime.
> (I haven't yet used OpenMCL's FFI for anything, so this is just idle
> speculation and not a feature request.)
A lot of ObjC code uses idioms like:
[new_view initWithFrame: NSMakePoint(x,y,width,height)]
That doesn't cost anything in ObjC, so I agree that it's desirable
to reduce the cost of doing the analagous thing in lisp.
I checked in some code which catches simple cases of this, and
changed some of the examples to call the constructor, trusting
the compiler to transform cases like A above into something like B.
> Kevin Reid <http://homepage.mac.com/kpreid/>
More information about the Openmcl-devel