# How does a custom block call inputs?

For example, in

[scratchblocks] define square at position (position x) (position y) size (size) rotated internally (internal rotation) and rotated around (rotation center x) (rotation center y) by (degree) square at position((position x) + (((rotation center x) * ((cos v) of (degree))) - ((rotation center y ) * ((sin v)of(degree))))) ((position y) + (((rotation center y) * ((cos v) of (degree))) - ((rotation center x) * ((sin v)of(degree))))) at size(size) rotated by (internal rotation)::#990099 [/scratchblocks]

([scratchblocks]define square at position(x) (y) at size (size) rotated by (angle)
pen up
go to x ( (x) + ((((x) - (size)) * ((cos v) of (angle))) - (((y) - (size)) * ((sin v)of(angle))))) y ( (y) + ((((x) - (size)) * ((sin v) of (angle))) + (((y)-(size)) * ((cos v)of(angle)))))
pen down
go to x ( (x) + ((((x) + (size)) * ((cos v) of (angle))) - (((y) - (size)) * ((sin v)of(angle))))) y ( (y) + ((((x) + (size)) * ((sin v) of (angle))) + (((y)-(size)) * ((cos v)of(angle)))))
go to x ( (x) + ((((x) + (size)) * ((cos v) of (angle))) - (((y) + (size)) * ((sin v)of(angle))))) y ( (y) + ((((x) + (size)) * ((sin v) of (angle))) + (((y) + (size)) * ((cos v)of(angle)))))
go to x ( (x) + ((((x) - (size)) * ((cos v) of (angle))) - (((y) + (size)) * ((sin v)of(angle))))) y ( (y) + ((((x) - (size)) * ((sin v) of (angle))) + (((y)+(size)) * ((cos v)of(angle)))))
go to x ( (x) + ((((x) - (size)) * ((cos v) of (angle))) - (((y) - (size)) * ((sin v)of(angle))))) y ( (y) + ((((x) - (size)) * ((sin v) of (angle))) + (((y)-(size)) * ((cos v)of(angle)))))
pen up[/scratchblocks])

Does it evaluate [scratchblocks](position x) + (((rotation center x) * ((cos v) of (degree))) - ((rotation center y ) * ((sin v)of(degree))))[/scratchblocks]
with every go to block, or does it evaluate them beforehand and then just call them every time?

It evaluates them beforehand and calls them every time.

No, it does not call them every time; it uses the same value that was evaluated. In Snap!, there are unevaluated types than can be used with call or run to evaluate them more than once.

I thought by 'call' they just meant refer the value

Wait, what? I think you guys are answering the wrong question (a different wrong question for each of you :~) ). What S_S wants to know is whether the common subexpressions of the four go to x: y: blocks are remembered in between the commands. And the answer is no; we don't do compiler-style global optimizations.

Do I win, @silver_star?

I don't know exactly what you mean, but between you, helicoptur, and snapenilk, I definitely understand a lot better. Thanks for clarifying.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.