{"id":20007406,"url":"https://github.com/mystpi/talon","last_synced_at":"2025-05-04T18:33:49.319Z","repository":{"id":39592364,"uuid":"444204916","full_name":"MystPi/talon","owner":"MystPi","description":"The Talon programming language","archived":false,"fork":false,"pushed_at":"2022-05-31T10:07:22.000Z","size":29,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-22T12:08:08.370Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MystPi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-01-03T21:30:33.000Z","updated_at":"2023-05-18T14:43:35.000Z","dependencies_parsed_at":"2022-09-20T05:40:43.998Z","dependency_job_id":null,"html_url":"https://github.com/MystPi/talon","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MystPi%2Ftalon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MystPi%2Ftalon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MystPi%2Ftalon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MystPi%2Ftalon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MystPi","download_url":"https://codeload.github.com/MystPi/talon/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252382780,"owners_count":21739214,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T06:16:25.143Z","updated_at":"2025-05-04T18:33:49.028Z","avatar_url":"https://github.com/MystPi.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# The Talon Programming Language\n\nTalon is a toy programming language with Python and JavaScript flavors.\n\n```talon\nfun factorial(n) {\n  if (n == 1) {\n    ret 1\n  } else {\n    ret n * factorial(n - 1)\n  }\n}\n\nthis f = factorial(4)\n\nprint(f) // -\u003e 24\n```\n\n```talon\nthis name = getstr('What is your name? ')\nthis length = len(name)\n\nprintf('Your name is %0; it has %1 characters.', [name, length])\n```\n\u003e You can view more demos in the [examples](examples/) folder.\n\n## Running and Compiling Code\nFirst you must install Talon.\n```bash\npip install talonlang\n```\nThen you can run Talon programs:\n```bash\ntal [-c] \u003cinput.tal[c]\u003e [-o \u003coutput.talc\u003e]\n```\n- The `-c` switches on compiling. If no `-o` flag is provided (along with a filename), the output file will be named according to the input file. Eg. `input.tal` to `input.talc`. (Note: you may compile already compiled code, but that is redundant and pointless.)\n- The `-o` flag changes the name of the output file. It can only be used if `-c` is present.\n- If the `-c` flag is not included, the interpreter will either\n  - compile and run the provided code if the file ends in `.tal`,\n  - or interpret the compiled code if the file extension is `.talc`.\n\n## Basic Syntax\nA basic rundown of Talon's syntax.\n\n### Comments\n\nSingle line:\n```\n// I'm a comment\nprint('Hello') // Another comment\n```\n\nMulti-line:\n```\n/*\n  This is a multi-line comment.\n  It can cover multiple lines.\n*/\n```\n\n### Variables\nVariables are initialized with the `this` keyword:\n```\nthis foo = bar\n```\nLike in JavaScript, values are *not* required when first initializing a variable:\n```\nthis x\n```\nHowever, re-initializing a variable results in an error:\n```\nthis name = 'Talon'\nthis name // ERROR\n```\nAssignment can be accomplished via a variety of operators:\n```\nthis n\nn = 1\nn += 2    // n = n + 2\nn -= 5    // n = n - 5\nn *= 7    // n = n * 7\nn /= 1.5  // n = n / 1.5\nn %= 3    // n = n % 3\nn ^= 20   // n = n ^ 20\n```\n\n### Values\n- Numbers\n  - Integer: `42`, `1`, `-67`\n  - Float: `3.1415`, `98.6`, `-1.168`\n- Strings\n  - Single-quoted: `'Hello!'`\n  - Double-quoted: `\"Good day!\"`\n- Booleans\n  - Truthy: `true`, `on`, `yes`\n  - Falsey: `false`, `off`, `no`\n- Lists\n  - Creating\n    - Single dimensional: `[1, 2, 3, 4]`\n    - Multi-dimensional: `[[1, 2], [3, 4]]`\n  - Accessing: `list[index]`, `list[index][index2]`\n  - Slicing: `list[:-1]`, `list[1:]`, `list[2:-2]`\n- Ranges\n  - Inclusive: `1 to 10`\n  - Exclusive: `1 upto 11`\n\n### Operators\n- Binary\n  - Addition: `a + b`\n  - Subtraction: `a - b`\n  - Multiplication: `a * b`\n  - Division: `a / b`\n  - Modulus: `a % b`\n  - Exponent: `a ^ b`\n- Unary\n  - Negation: `-x`\n  - Absolute value: `+x`\n  - Not: `!x`\n- Comparing\n  - Equals: `a == b`\n  - Not equals: `a != b`\n  - Less than: `a \u003c b`\n  - Greater than: `a \u003e b`\n  - Less than or equal to: `a \u003c= b`\n  - Greater than or equal to: `a \u003e= b`\n- Boolean\n  - And: `a \u0026\u0026 b`\n  - Or: `a || b`\n\n### Conditional Statements\n```\nif (/* condition */) {\n  ...\n} else if (/* condition */) {\n  ...\n} else {\n  ...\n}\n```\n\n### Loops\nWhile loop:\n```\nthis i = 0\n\nwhile (i \u003c 10) {\n  print(i)\n  i += 1\n}\n```\nFor loop:\n```\nthis i\n\nfor (i in 1 to 10) {\n  print(i)\n}\n```\n```\nthis alphabet = 'abcdefghijklmnopqrstuvwxyz'\nthis letter\n\nfor (letter in alphabet) {\n  printf('The letter is %0.', [letter])\n}\n```\n\n### Functions\nFunctions can be created by a variety of methods:\n```\nfun foo(bar) {\n  ret bar * 2\n}\n```\n```\nthis foo = fun (bar) {\n  ret bar * 2\n}\n```\n```\nthis foo = (bar) -\u003e {\n  ret bar * 2\n}\n```\n```\nthis foo = (bar) -\u003e (bar * 2)\n```\nThey have their own scope:\n```\nfun scope() {\n  this x = 2\n  x = 5\n  y = 6\n}\n\nthis x = 1\nthis y = 1\n\nscope()\n\nprint(x, y) // 1, 6\n```\n\n### Imports\nCurrently very limited, importing allows you to import functions and variables from other Talon scripts.\n\n```\n// a.tal\n\nimport('b.tal')\n\nprint(add(1, 2)) // 3\n```\n```\n// b.tal\n\nfun add(a, b) {\n  ret a + b\n}\n```\n\n\u003e Hopefully namespaces (which aren't yet supported) will be implemented in the future.\n\u003e ```\n\u003e import('b.tal', 'b')\n\u003e\n\u003e print(b.add(1, 2))\n\u003e ```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmystpi%2Ftalon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmystpi%2Ftalon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmystpi%2Ftalon/lists"}