{"action":"created","issue":{"url":"https://api.github.com/repos/alda-lang/alda/issues/7","labels_url":"https://api.github.com/repos/alda-lang/alda/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/alda-lang/alda/issues/7/comments","events_url":"https://api.github.com/repos/alda-lang/alda/issues/7/events","html_url":"https://github.com/alda-lang/alda/issues/7","id":54280601,"number":7,"title":"Implement repeats, variables & modules","user":{"login":"daveyarwood","id":4909079,"avatar_url":"https://avatars.githubusercontent.com/u/4909079?v=3","gravatar_id":"","url":"https://api.github.com/users/daveyarwood","html_url":"https://github.com/daveyarwood","followers_url":"https://api.github.com/users/daveyarwood/followers","following_url":"https://api.github.com/users/daveyarwood/following{/other_user}","gists_url":"https://api.github.com/users/daveyarwood/gists{/gist_id}","starred_url":"https://api.github.com/users/daveyarwood/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daveyarwood/subscriptions","organizations_url":"https://api.github.com/users/daveyarwood/orgs","repos_url":"https://api.github.com/users/daveyarwood/repos","events_url":"https://api.github.com/users/daveyarwood/events{/privacy}","received_events_url":"https://api.github.com/users/daveyarwood/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/alda-lang/alda/labels/feature","name":"feature","color":"eb6420"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-01-14T03:39:42Z","updated_at":"2015-09-07T16:32:11Z","closed_at":null,"body":"(None of these are yet defined in the grammar or implemented in the parser behavior.)\r\n\r\n**Repeats**\r\n\r\nSelf-explanatory. e.g. `c1(~1)x7` should expand to `c1~1~1~1~1~1~1~1` at compile time.\r\n\r\n**Variables**\r\n\r\nVariables should work like they do in Lilypond. Any piece of code can be enclosed in brackets and defined as a variable, then called in the code any number of times, at any point in time.\r\n\r\nDesired syntax:\r\n\r\n    # Defining a variable: \r\n    riffA = [f8 f g+ a > c c d c <]\r\n    riffB = [b-8 b- > c+ d f f g f <]\r\n    riffC = [> c8 c d+ e g g a g < ]\r\n    riffD = [f8 f g+ a > c c d < b > | c c < b- b- a a g g]\r\n\r\n    # calling a variable\r\n    $riffA # expands to \"f8 f g+ a > c c d c <\"\r\n\r\n    # using variables + repeats\r\n    ($riffA)x4 \r\n    ($riffB)x2  ($riffA)x2\r\n    $riffC $riffB $riffD\r\n\r\n    # bonus: conglomerate variables into other variables!\r\n    rockinRiff = \r\n      [ ($riffA)x4 \r\n        ($riffB)x2  ($riffA)x2\r\n        $riffC $riffB $riffD    ] \r\n\r\n    guitar/saxophone: \r\n        ($rockinRiff) x9999999\r\n\r\n**Modules**\r\n\r\nTake the variable concept and apply it to entire files.\r\n\r\nFor example, each instrument's part could be written in a separate file in the same directory as a main file, then in the main file (say, \"score.alda\"), you could write something like:\r\n\r\n    &clarinet.alda\r\n    &trombone.alda\r\n    &tuba.alda\r\n    &banjo.alda\r\n    &piano.alda\r\n    &drums.alda\r\n\r\nand each of these statements would be replaced by the contents of each file at compile time.\r\n\r\nThis would be especially cool in that you could define custom instruments (e.g. custom synth instruments) as standalone files and then load them in as modules in any piece of music in which you'd like to use them.\r\n\r\nNOTE: Modules might be a little tricky to implement and preserve line numbers for error reporting. Ideally we'd be able to report the line/column number and name of the file where the error occurred."},"comment":{"url":"https://api.github.com/repos/alda-lang/alda/issues/comments/138336052","html_url":"https://github.com/alda-lang/alda/issues/7#issuecomment-138336052","issue_url":"https://api.github.com/repos/alda-lang/alda/issues/7","id":138336052,"user":{"login":"8dx","id":328575,"avatar_url":"https://avatars.githubusercontent.com/u/328575?v=3","gravatar_id":"","url":"https://api.github.com/users/8dx","html_url":"https://github.com/8dx","followers_url":"https://api.github.com/users/8dx/followers","following_url":"https://api.github.com/users/8dx/following{/other_user}","gists_url":"https://api.github.com/users/8dx/gists{/gist_id}","starred_url":"https://api.github.com/users/8dx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/8dx/subscriptions","organizations_url":"https://api.github.com/users/8dx/orgs","repos_url":"https://api.github.com/users/8dx/repos","events_url":"https://api.github.com/users/8dx/events{/privacy}","received_events_url":"https://api.github.com/users/8dx/received_events","type":"User","site_admin":false},"created_at":"2015-09-07T16:32:11Z","updated_at":"2015-09-07T16:32:11Z","body":"Absolutely  brilliant concept. +1 to this, would increase and improve the fork and brevity of this concept. Like shia said, JUST DO IT "}}