{"action":"opened","issue":{"url":"https://api.github.com/repos/google/codeworld/issues/780","repository_url":"https://api.github.com/repos/google/codeworld","labels_url":"https://api.github.com/repos/google/codeworld/issues/780/labels{/name}","comments_url":"https://api.github.com/repos/google/codeworld/issues/780/comments","events_url":"https://api.github.com/repos/google/codeworld/issues/780/events","html_url":"https://github.com/google/codeworld/issues/780","id":384654475,"node_id":"MDU6SXNzdWUzODQ2NTQ0NzU=","number":780,"title":"Define colors as pattern synonyms?","user":{"login":"cdsmith","id":544744,"node_id":"MDQ6VXNlcjU0NDc0NA==","avatar_url":"https://avatars1.githubusercontent.com/u/544744?v=4","gravatar_id":"","url":"https://api.github.com/users/cdsmith","html_url":"https://github.com/cdsmith","followers_url":"https://api.github.com/users/cdsmith/followers","following_url":"https://api.github.com/users/cdsmith/following{/other_user}","gists_url":"https://api.github.com/users/cdsmith/gists{/gist_id}","starred_url":"https://api.github.com/users/cdsmith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cdsmith/subscriptions","organizations_url":"https://api.github.com/users/cdsmith/orgs","repos_url":"https://api.github.com/users/cdsmith/repos","events_url":"https://api.github.com/users/cdsmith/events{/privacy}","received_events_url":"https://api.github.com/users/cdsmith/received_events","type":"User","site_admin":false},"labels":[{"id":111257421,"node_id":"MDU6TGFiZWwxMTEyNTc0MjE=","url":"https://api.github.com/repos/google/codeworld/labels/proposal","name":"proposal","color":"5319e7","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-11-27T07:11:56Z","updated_at":"2018-11-27T07:11:56Z","closed_at":null,"author_association":"COLLABORATOR","body":"One problem that I run into when teaching early functions is that equations cannot be written for specific colors without using RGB or HSL form.  That is, one can't write:\r\n\r\n    f(red) = colored(ball, red)\r\n    f(blue) = colored(ball, blue)\r\n\r\nand so on.  This is inconvenient, because:\r\n\r\n1. Colors are the strongest early examples of user-defined function arguments.  (\"What if you wanted to draw people with many different hair colors?\")\r\n2. It seems to work well to introduce functions by writing specific equations first, then generalizing the pattern after a few equations have already been written.  I'd like students to be able to *actually* do that in code... but it doesn't work, because `f(red) = colored(ball, red)` is *already* the generalized pattern, entirely by accident.\r\n\r\nOne could easily redefine the built-in colors as pattern synonyms (as `Red` instead of `red`).  The advantage would be that the introduction of functions would go more smoothly.  If we did this, we would probably also change `pi` to `Pi`, as well, and maybe other analogous cases.  Note that `Bool`, `Text`, and `Number` literal expressions already have pattern forms, so `Color` and `Picture` are the only exceptions here.\r\n\r\nThe disadvantage is that the introduction of *colors* would break rules, leading to questions about why these are capitalized.  That's a conversation we're definitely not ready to have so early in the class.  I'd have to hide behind vague language about \"Red is more like a literal value than a variable\" or something like that.  And we can't entirely hide the issue, since expressions like `sqrt(2)` or `1/2` are also not usable as function arguments."}}
{"actor":{"display_login":"cdsmith"}}