{"id":13779066,"url":"https://github.com/picrin-scheme/libpicrin","last_synced_at":"2025-05-11T12:32:39.101Z","repository":{"id":20033659,"uuid":"23301755","full_name":"picrin-scheme/libpicrin","owner":"picrin-scheme","description":"Super Tiny Scheme Interpreter for Freestanding Environment","archived":true,"fork":false,"pushed_at":"2017-04-23T09:00:30.000Z","size":3041,"stargazers_count":55,"open_issues_count":0,"forks_count":7,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-11-17T14:41:20.255Z","etag":null,"topics":["embedded","gc","programming-language","scheme"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/picrin-scheme.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-25T04:26:47.000Z","updated_at":"2024-09-13T04:51:55.000Z","dependencies_parsed_at":"2022-08-27T04:01:04.819Z","dependency_job_id":null,"html_url":"https://github.com/picrin-scheme/libpicrin","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/picrin-scheme%2Flibpicrin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/picrin-scheme%2Flibpicrin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/picrin-scheme%2Flibpicrin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/picrin-scheme%2Flibpicrin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/picrin-scheme","download_url":"https://codeload.github.com/picrin-scheme/libpicrin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253567203,"owners_count":21928797,"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":["embedded","gc","programming-language","scheme"],"created_at":"2024-08-03T18:01:00.642Z","updated_at":"2025-05-11T12:32:38.803Z","avatar_url":"https://github.com/picrin-scheme.png","language":"C","funding_links":[],"categories":["C"],"sub_categories":[],"readme":"# libpicrin\n\nlibpicrin is a super tiny scheme interpreter intended to be embedded in other applications such as game engine and network server. It provides a subset language of R7RS with several useful extensions. By default, libpicrin only contains some C files and headers and this README file. To embed, you only need to copy the files into the project and add `include` dir to the include path.\n\nOriginally, libpicrin used to be the core component of [Picrin Scheme](https://github.com/picrin-scheme/picrin). They are currently maintained at separate repositories.\n\n## Example\n\n```c\n#include \u003cstdio.h\u003e\n\n#include \"picrin.h\"\n#include \"picrin/extra.h\"\n\n/* Simple REPL program */\n\nint\nmain(int argc, char *argv[])\n{\n  pic_state *pic;\n  pic_value expr;\n\n  pic = pic_open(pic_default_allocf, NULL);\n\n  while (1) {\n    printf(\"\u003e \");\n\n    expr = pic_read(pic, pic_stdin(pic));\n\n    if (pic_eof_p(pic, expr)) {\n      break;\n    }\n\n    pic_printf(pic, \"~s\\n\", pic_eval(pic, expr, \"picrin.user\"));\n  }\n\n  pic_close(pic);\n\n  return 0;\n}\n```\n\n## More Example\n\nFunction binding is also easy. `pic_defun` defines a scheme procedure converting from a C function. In the native function, callee arguments can be taken with `pic_get_args`. `pic_get_args` gets arguments according to the format string. If actual arguments does not match a number or incompatible types, it will raise an exception.\n\n```c\n#include \"picrin.h\"\n#include \"picrin/extra.h\"\n\nint fact(int i) {\n  return i == 1 ? 1 : i * fact(i - 1);\n}\n\npic_value factorial(pic_state *pic) {\n  int i;\n\n  pic_get_args(pic, \"i\", \u0026i);\n\n  return pic_int_value(pic, fact(i));\n}\n\nint\nmain(int argc, char *argv[])\n{\n  pic_state *pic = pic_open(pic_default_allocf, NULL);\n\n  pic_defun(pic, \"fact\", factorial); /* define fact procedure */\n\n  pic_load_cstr(pic, \"(display (fact 10))\");\n\n  pic_close(pic);\n\n  return 0;\n}\n```\n\n## Language\n\nAll procedures and syntaces are exported from a single library named `(picrin base)`. The complete list is found at https://gist.github.com/wasabiz/344d802a2340d1f734b7 .\n\n### call/cc\n\nFull continuation has many problems in embbeding into applications. By default, libpicrin's call/cc operator does not support continuation that can handle re-entering (it only supports escape continuations). To remove this restriction, please use an add-on provided from [Picrin Scheme's repository](https://github.com/picrin-scheme/picrin/tree/master/contrib/03.callcc).\n\n### Strings\n\nlibpicrin utilize rope data structure to implement string type. Thanks to the implementation, string-append is guaranteed to be done in a constant time (so do string-copy, when ascii-only mode is enabled). In return for that, strings in libpicrin are immutable by default. It does not provide mutation API (string-set!, string-copy! and string-fill! in R7RS). This restriction can be also removed with an add-on in [Picrin Scheme's repository](https://github.com/picrin-scheme/picrin/tree/master/contrib/03.mutable-string).\n\n### Dictionaries\n\nDictionary is a hash table from symbol to object.\n\n## Authors\n\nSee https://github.com/picrin-scheme/picrin for details.\n\n## LICENSE\n\nCopyright (c) 2013-2017 Yuichi Nishiwaki and other picrin contributors\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\nthe Software, and to permit persons to whom the Software is furnished to do so,\nsubject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\nCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\nIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpicrin-scheme%2Flibpicrin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpicrin-scheme%2Flibpicrin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpicrin-scheme%2Flibpicrin/lists"}