<div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Hi Marc,</div><div><br>Cool, wonderful!</div><div><br></div><div><br></div><div>Yeah for any situation like</div><div><br></div><div>(define (a)</div><div>  ; Teleport from hr</div><div>  (b))</div><div>(define (b) (c))</div><div>(define (c)</div><div>  ; Teleport to hr</div><div>  #!void)</div><div><br></div><div>, just totally great.</div><div><br></div><div><br></div><div>Your subsequent email re. "(make-timeout-handler 5 (lambda () …))))" usecase and "I think that is a better API." comment I believe I fully agree with, also that's neat, it illustrates how this is useful on the runtime-interacts-with-userland level.</div><div><br></div><div><br></div><div>Thinking back, all my parameter objects until now have been global variables. This also means that, for a given sourcecode file, the number of parameter objects has been pre-specified. In this kind of usage situation, would any optimization trick be possible? E.g. could the "current input port or one of the last 3 accessed parameters" set be extended with a copy of each of that fixed set of toplevel parameter objects and so accordingly their parameterization and access be O(1) always.</div><div><br></div><div><br></div><div>(This email was primarily to learn what kind of time characteristics parameterized objects have, given how great they are.)<br></div><div><br></div><div>Adam</div><div><br></div></div></div></div><br><div class="gmail_quote"><div class="gmail_attr" dir="ltr">On Sun, 8 Mar 2020 at 23:00, Marc Feeley <<a href="mailto:feeley@iro.umontreal.ca">feeley@iro.umontreal.ca</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid">The dynamic environment is implemented as a hybrid structure that combines a dictionary (implemented as a binary tree), with a special case for the frequently accessed parameters (current-input-port, etc), and a cache of the last 3 parameters that were accessed.<br>
<br>
So if you access the current input port or one of the last 3 accessed parameters, the time complexity is O(1).  Otherwise it is O(log N) where N is the number of bindings in the environment.<br>
<br>
I may change the binary tree to a table once the functional API to tables is fully implemented.<br>
<br>
So I think the complexity is pretty good, but obviously much slower than an access to a lexical variable.  I’ll let you do some benchmarking to determine the hidden constant.<br>
<br>
Marc<br>
<br>
<br>
<br>
> On Mar 8, 2020, at 10:44 AM, Adam <<a href="mailto:adam.mlmb@gmail.com" target="_blank">adam.mlmb@gmail.com</a>> wrote:<br>
> <br>
> Hi Marc,<br>
> <br>
> I can't recall if this is somewhere in the mailing list archive from before:<br>
> <br>
> I recall that you indicated that parameter objects are expensive.<br>
> <br>
> Would you mind describing/quantifying the average/worst case/best case cost for assigning a value to a parameter object by parameterization (|parameterize|), and for accessing a parameter object (load or store operation by invoking it as a closure)?<br>
> <br>
> Parameter objects are very practical and have ample use scenarios, both high-level and relatively low-level.<br>
> <br>
> Thanks,<br>
> Adam<br>
<br>
<br>
</blockquote></div>