<div dir="ltr">Yeah, I didn't really think it was a good idea. It just seemed like a clever trick and a challenge to see if I could get it to work.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jun 11, 2024 at 6:35 PM Andres Valloud via Cuis-dev <<a href="mailto:cuis-dev@lists.cuis.st">cuis-dev@lists.cuis.st</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">There should be a mirror-type virtual machine or perhaps debugger API to <br>
send a message to an object without using perform:withArguments:.<br>
<br>
It doesn't seem to me it's a good idea, though. For example, what <br>
happens when one of your instance variables has a name that matches a <br>
unary selector defined by a superclass? Also, it's going to be very <br>
slow. And debugging is impeded by coalescing a multitude of specific <br>
locations to place a breakpoint into an overly general one.<br>
<br>
On 6/11/24 4:29 PM, Mark Volkmann via Cuis-dev wrote:<br>
> A thought occurred to me that I could override the instance method <br>
> `doesNotUnderstand` in a class to avoid writing a bunch of basic <br>
> accessor methods. Setting aside whether it's ever a good idea to have a <br>
> getter and setter method for every instance variable in a class, I <br>
> thought I could do it like this:<br>
> <br>
> doesNotUnderstand: aMessage<br>
> "gets or sets an instance variable"<br>
> <br>
> | argCount getters key setters value |<br>
> <br>
> argCount := aMessage numArgs.<br>
> argCount > 1 ifTrue: [ ^super doesNotUnderstand: aMessage ].<br>
> <br>
> key := aMessage keywords first.<br>
> getters := self class allInstVarNames.<br>
> setters := getters collect: [ :name | name, ':' ].<br>
> (getters, setters includes: key) ifFalse: [ ^super doesNotUnderstand: <br>
> aMessage ].<br>
> <br>
> argCount = 0 ifTrue: [ ^self perform: key ].<br>
> <br>
> value := aMessage arguments first.<br>
> self perform: key with: value<br>
> <br>
> But this goes into an infinite loop because sending the `perform:` <br>
> message ends up hitting `doesNotUnderstand` again. Is there a way I <br>
> could make this work?<br>
> <br>
> -- <br>
> R. Mark Volkmann<br>
> Object Computing, Inc.<br>
> <br>
-- <br>
Cuis-dev mailing list<br>
<a href="mailto:Cuis-dev@lists.cuis.st" target="_blank">Cuis-dev@lists.cuis.st</a><br>
<a href="https://lists.cuis.st/mailman/listinfo/cuis-dev" rel="noreferrer" target="_blank">https://lists.cuis.st/mailman/listinfo/cuis-dev</a><br>
</blockquote></div><br clear="all"><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div><font face="arial, helvetica, sans-serif">R. Mark Volkmann</font></div><div><span style="font-size:12.8px"><font face="arial, helvetica, sans-serif">Object Computing, Inc.</font></span></div></div></div></div></div></div></div></div>