<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
On 26.04.2011 16:31, Mariano Martinez Peck wrote:
<blockquote
cite="mid:BANLkTi=+pOi7ix6LS4y6Kxr5QFq19g2tCw@mail.gmail.com"
type="cite">
<pre wrap=""> </pre>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<br>
<br>
<div class="gmail_quote">On Tue, Apr 26, 2011 at 12:50 PM, Henrik
Sperre Johansen <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:henrik.s.johansen@veloxit.no">henrik.s.johansen@veloxit.no</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
0.8ex; border-left: 1px solid rgb(204, 204, 204);
padding-left: 1ex;">
<br>
Say you have Class A:<br>
inst vars : one two three<br>
<br>
and method compiled on it:<br>
foo<br>
^one<br>
<br>
Then you also have Class B:<br>
inst vars: three two one<br>
<br>
Then you do<br>
methodFoo := A >> #foo<br>
methodFoo executeWithReceiver: B new one: 1; three: 3;
yourself arguments:<br>
#()<br>
<br>
It'll return 3, which'll probably confuse those not very
familiar with the<br>
bytecodes.<br>
<br>
Or using a class with no instvars, it'll crash in a similar
manner to what<br>
you get if you currently do:<br>
Test methodDictionary at: #foo put: MCPackage >>
#packageInfo.<br>
Test >> #foo.<br>
Test new foo<br>
</blockquote>
<div><br>
You see, now I got it :) I am just slow. <br>
Thanks Henrik for this example. In fact, it was not even
obvious for me until you told me. The "problem" is that the
bytecodes to access/set instanceVariables work by position
instead of name, no?<br>
I mean, 'one' is never put in the literals of A >> #foo
<br>
</div>
</div>
</blockquote>
yup, instvar access in byte codes is indexed.<br>
<br>
<blockquote
cite="mid:BANLkTi=+pOi7ix6LS4y6Kxr5QFq19g2tCw@mail.gmail.com"
type="cite">
<div class="gmail_quote">
<div><br>
Nevertheless, exactly the same happens with
#valueWithReceiver:arguments: so...ok, we have this problem
but we also have from before ;)<br>
right ?<br>
</div>
</div>
</blockquote>
Dunno, I only commented on the code you posted.<br>
<blockquote
cite="mid:BANLkTi=+pOi7ix6LS4y6Kxr5QFq19g2tCw@mail.gmail.com"
type="cite">
<div class="gmail_quote">
<div><br>
solutions?<br>
<br>
First I would put a nice comment in
#valueWithReceiver:arguments: and
#valueWithReceiver:arguments: <br>
<br>
Second, if I understood you correctly you mean to do in your
previous email, you want to validate that the class of the
receiver is the same as the class where the CompiledMethod is
installed and if it is not, throw an error ?<br>
<br>
On the one hand that would limit a bit the usage because that
fails only when there is instance var access, doesn't it? On
the other hand, it prevents some crashes or weird cases where
the results are not the expected ones. <br>
<br>
Opinions?<br>
</div>
</div>
</blockquote>
Not sure if the overhead of such a check would be worth it.<br>
The least restrictive to avoid outright crashing would probably be
to check that instvar accessing bytescodes in the method did not
exceed that of the receiver, but a class check would probably be
simpler.<br>
<br>
I'd be ok with just a good comment, one would expect users of this
to sort of know what they are doing.<br>
On the other hand, you didn't realize it untill I pointed it out
specifically ;)<br>
<br>
If it should be allowed at all, as per Igor's post.<br>
<br>
I love disagreeing with myself :D<br>
<br>
Cheers,<br>
Henry<br>
<br>
</body>
</html>