Easy Library to pair a getter with a setter together that rhymes :) in a list, and ‘set’ and ‘change’ the value of the getter using the setter.
Snap! Pairs
so, what do you think?
Sorry - I’ve no idea what they do
you create a pair from a ‘setter’ block and a ‘getter’ block. say, you made a pair with the setter: set x to () and getter: x position, use the ‘set pair [pair] to (value)’ block to set the ‘getter’ or in this case, the x position to that value.
I can see that this was a useful learning exercise for you, but I don’t really see the utility of wrapping these blocks around built-in getters and setters such as POSITION. I suppose you could use this to build collections of primitive state, like this:
… but in order to make this work I had to undo the fancy setting of the pair name in your _ OF PAIR _ block, so that I could leave that input slot empty. Note also that without the PEN UP in my SET STATE block, it’d draw an unwanted line if the pen is down when you call it, so I had to do some thinking about the specific properties of the list of state components, and I also had to be sure PEN DOWN? comes after POSITION in my list.
I think this would be more useful for abstract state pairs, so you’d say
![]()
and then you could say
![]()
and then
![]()
would report 87.
The reason someone may want to use s getter, is if they want to transform or generate a value without storing it in a variable or having to explicitly call a function (you are still calling a function, it’s just not explicit). I do not see any use case in snap to use getters, because custom reporters are essentially getters, and snap doesn’t have a specific syntax for calling functions (blocks).
Honeslty, I agree. There should be built-in, primitive pairs for this, but i suggest we keep the
block since it could be used to make these primitives. (and because i spent way too long making this)
I updated the project to support these ‘primitive pairs’
(also please turn plain prototype labels off, i dont really like this look)
Those already exist. They’re called variables. (or scope vars, which i made already)
(and i use this character (ⵓ) for the icons, not the colon (:))
the reasons i created pairs is:
- organizing a custom setter with a custom getter
- keeping projects slightly more neat.
- just for fun (had nothing else to do today)
trying to change the position attribute and accidently drawing a line on the canvas would be annoying, so i added the ability to ignore the pen lines when a pair is being edited. (this is turned off by default though, and can be toggled using the
block)
(and i use this character (ⵓ) for the icons, not the colon (:))
Yeah, I couldn’t be bothered putzing around with Unicode, and I figured you’d get the idea, as you did. :~)
Those already exist. They’re called variables.
All of this already exists! You’re just wrapping some notation around it.
just for fun
Good reason! Keep it up (having fun, I mean).


