Suggestions for the assoc block

  1. Change the name of the block from this:
    untitled script pic (16)
    to this:
    untitled script pic (17)
    Snap! is supposed to be a visual programming language, and names that describe what the block does are more helpful. A short name like "assoc" makes sense in a text-based programming language, because you can type short names faster than long ones, but it doesn't make sense in Snap!.

  2. Instead of returning the key/value pair, maybe it should just return the value? In this case, the code would be changed to


    I feel like it would be more useful to just return the value.

I think it should return the pair because you could change its value (or key) [scratchblocks] replace item (2 v) of [] with [] [/scratchblocks].

It's still easy to get the value [scratchblocks] (item (2 v) of []) [/scratchblocks].

Yeah, you're probably right about the name. I'm not quite happy with "starting with," because that obscures the purpose for having such a block. How about find pair with key? It should really be find key-value pair with key but that's way too long. Another possibility would be find key which would be nice and short but doesn't tell the complete story about what it reports. Or yet another: find kv pair with key which requires you to read the help screen the first time you see it. :~) Any votes?

you could name it the Smalltalk way: (dict) at (key) and (dict) at (key) put (value)..

I'm not sure "at" is any better than "assoc" at helping a beginner figure it out. We already have the (color) at (position) block, for example.

yeah, you're probably right. I'm actually fine with assoc or even "variable".

You have the Variables library on the brain! :~) There are other uses for dictionaries besides that. Assoc has the virtue that you can look it up online and find more than you want to know about what it does. But it's not very Scratchly.

Really? Huh, I would have never guessed googling/go-duck-go-ing would give any meaningful hits for such a cryptic word as "assoc" appears to be, at least to a lay user such as me. But you could maybe add this to the block's help screen, regardless of how it may be renamed.

it's duck-duck-go-ing

Why? I understand that the word "starting" here means the first item of the "key, value" pair because it is starting with the key and finishing with the value.

Huh, you're right. It's at the very bottom of the first page of Google results. "Lisp assoc" works. :~)

The problem is that item 1 of, which is what "starting" means, is useful for many things besides dictionaries; in particular, it's used in recursive list functions. I want something more specific to dictionary lookup. Maybe find _ in dictionary _?

What about "what starts with __ in __" ?

I really like this one. Yes!

Nah, too much like "what's a seven-letter word starting with Q?" The name really should suggest dictionaries or alists or at least pairs.

By missing off just one of the words, the block wouldn't have to be longer than the longest existing library block

image

I meant to say earlier, it's precisely for cryptic words that you expect perfect search results! I mean, look up "desuitude," for example, or "diverticulosis." The problem with "assoc" is that it's a commonly used abbreviation for "association," as in "a group of people."

How about key-value pair, key: _ in _?

Yeah, what I meant by 'cryptic' was in fact C.U.A., but in the heat of discussion I just couldn't recall a one-word term for C.U.A., so I took chances with the similar word knowing that you will probably - as a good teacher that you are needs to do all the time - read my mind. It turned out you did.

Nah, the one you proposed earlier is much better because a lay person knows what to expect as soon as s/he sees the word 'dictionary'. Everyone knows that one is searching for a keyword in a dictionary to get the value (a translation or a lexicographic description of the word).

I don't think "dictionary" is a Snap! thing.

We are using 2D lists with keys as our dictionary containers but there are no blocks that use the word dictionary.

The Snap! terminology (at present time) is key-value pairs.

If we try to have the dictionary discussion at this time - we'll never sort out the assoc block :slight_smile: