"use strict";(self.webpackChunkdocs=self.webpackChunkdocs||[]).push([["9940"],{4256:function(e,t,s){s.r(t),s.d(t,{default:()=>m,frontMatter:()=>a,metadata:()=>n,assets:()=>c,toc:()=>d,contentTitle:()=>l});var n=JSON.parse('{"id":"languages/commonlisp","title":"Common Lisp","description":"Common Lisp is a dialect of the Lisp programming language.","source":"@site/docs/languages/commonlisp.mdx","sourceDirName":"languages","slug":"/languages/commonlisp","permalink":"/docs/languages/commonlisp","draft":false,"unlisted":false,"editUrl":"https://github.com/live-codes/livecodes/tree/develop/docs/docs/languages/commonlisp.mdx","tags":[],"version":"current","frontMatter":{},"sidebar":"docsSidebar","previous":{"title":"CoffeeScript","permalink":"/docs/languages/coffeescript"},"next":{"title":"C/C++ (Wasm)","permalink":"/docs/languages/cpp-wasm"}}'),o=s("5893"),i=s("65"),r=s("3365");let a={},l="Common Lisp",c={},d=[{value:"Usage",id:"usage",level:2},{value:"JS Interoperability",id:"js-interoperability",level:3},{value:"Language Info",id:"language-info",level:2},{value:"Name",id:"name",level:3},{value:"Aliases/Extensions",id:"aliasesextensions",level:3},{value:"Editor",id:"editor",level:3},{value:"Compiler",id:"compiler",level:2},{value:"Code Formatting",id:"code-formatting",level:2},{value:"Limitations",id:"limitations",level:2},{value:"Starter Template",id:"starter-template",level:2},{value:"Links",id:"links",level:2}];function h(e){let t={a:"a",admonition:"admonition",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",li:"li",p:"p",ul:"ul",...(0,i.a)(),...e.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(t.header,{children:(0,o.jsx)(t.h1,{id:"common-lisp",children:"Common Lisp"})}),"\n",(0,o.jsxs)(t.p,{children:[(0,o.jsx)(t.a,{href:"https://common-lisp.net/",children:"Common Lisp"})," is a dialect of the Lisp programming language."]}),"\n",(0,o.jsxs)(t.p,{children:["In LiveCodes, Common Lisp code runs in the browser using ",(0,o.jsx)(t.a,{href:"https://github.com/jscl-project/jscl",children:"JSCL"}),", a Common Lisp to JavaScript compiler."]}),"\n",(0,o.jsx)(t.admonition,{title:"Note",type:"info",children:(0,o.jsxs)(t.p,{children:["Lisp language family supported in LiveCodes includes ",(0,o.jsx)(t.a,{href:"/docs/languages/commonlisp",children:"Common Lisp"}),", ",(0,o.jsx)(t.a,{href:"/docs/languages/scheme",children:"Scheme"}),", ",(0,o.jsx)(t.a,{href:"/docs/languages/clojurescript",children:"ClojureScript"})," and ",(0,o.jsx)(t.a,{href:"/docs/languages/fennel",children:"Fennel"}),"."]})}),"\n",(0,o.jsx)(t.h2,{id:"usage",children:"Usage"}),"\n",(0,o.jsx)(t.p,{children:"LiveCodes runs Common Lisp code in the browser. JSCL implements a subset of Common Lisp, but covers enough functionality to write practical code."}),"\n","\n",(0,o.jsx)(t.p,{children:"This example demonstrates basic Common Lisp syntax and functionality:"}),"\n",(0,o.jsx)(r.Z,{template:"commonlisp",height:"80vh"}),"\n",(0,o.jsx)(t.h3,{id:"js-interoperability",children:"JS Interoperability"}),"\n",(0,o.jsxs)(t.p,{children:["Please see ",(0,o.jsx)(t.a,{href:"https://github.com/jscl-project/jscl/wiki/JSCL-and-manipulations-with-JS-objects",children:"JSCL docs"})]}),"\n",(0,o.jsx)(t.h2,{id:"language-info",children:"Language Info"}),"\n",(0,o.jsx)(t.h3,{id:"name",children:"Name"}),"\n",(0,o.jsx)(t.p,{children:(0,o.jsx)(t.code,{children:"commonlisp"})}),"\n",(0,o.jsx)(t.h3,{id:"aliasesextensions",children:"Aliases/Extensions"}),"\n",(0,o.jsxs)(t.p,{children:[(0,o.jsx)(t.code,{children:"common-lisp"}),", ",(0,o.jsx)(t.code,{children:"lisp"})]}),"\n",(0,o.jsx)(t.h3,{id:"editor",children:"Editor"}),"\n",(0,o.jsx)(t.p,{children:(0,o.jsx)(t.code,{children:"script"})}),"\n",(0,o.jsx)(t.h2,{id:"compiler",children:"Compiler"}),"\n",(0,o.jsxs)(t.p,{children:[(0,o.jsx)(t.a,{href:"https://github.com/jscl-project/jscl",children:"JSCL"})," - Common Lisp to JavaScript compiler"]}),"\n",(0,o.jsx)(t.h2,{id:"code-formatting",children:"Code Formatting"}),"\n",(0,o.jsxs)(t.p,{children:["Using ",(0,o.jsx)(t.a,{href:"https://shaunlebron.github.io/parinfer/",children:"Parinfer"}),"."]}),"\n",(0,o.jsx)(t.h2,{id:"limitations",children:"Limitations"}),"\n",(0,o.jsxs)(t.p,{children:["Since JSCL is a subset of Common Lisp, it doesn't implement all Common Lisp features. See the ",(0,o.jsx)(t.a,{href:"https://github.com/jscl-project/jscl#status",children:"JSCL documentation"})," for more information."]}),"\n",(0,o.jsx)(t.h2,{id:"starter-template",children:"Starter Template"}),"\n",(0,o.jsx)(t.p,{children:(0,o.jsx)(t.a,{href:"https://livecodes.io/?template=commonlisp",children:"https://livecodes.io/?template=commonlisp"})}),"\n",(0,o.jsx)(t.h2,{id:"links",children:"Links"}),"\n",(0,o.jsxs)(t.ul,{children:["\n",(0,o.jsx)(t.li,{children:(0,o.jsx)(t.a,{href:"https://common-lisp.net/",children:"Common Lisp"})}),"\n",(0,o.jsx)(t.li,{children:(0,o.jsx)(t.a,{href:"https://github.com/jscl-project/jscl",children:"JSCL"})}),"\n",(0,o.jsx)(t.li,{children:(0,o.jsx)(t.a,{href:"https://www.cs.cmu.edu/~dst/LispBook/",children:"Common Lisp: A Gentle Introduction to Symbolic Computation"})}),"\n",(0,o.jsx)(t.li,{children:(0,o.jsx)(t.a,{href:"http://www.gigamonkeys.com/book/",children:"Practical Common Lisp"})}),"\n"]})]})}function m(e={}){let{wrapper:t}={...(0,i.a)(),...e.components};return t?(0,o.jsx)(t,{...e,children:(0,o.jsx)(h,{...e})}):h(e)}},3365:function(e,t,s){s.d(t,{Z:()=>f});var n=s("5893"),o=s("4200"),i=s("7294"),r=s("8294");function a(e){let t=(0,i.useRef)(null),[s,o]=(0,i.useState)(e.className||""),[a,l]=(0,i.useState)(e.style||{}),[c,d]=(0,i.useState)(e.height),[h,m]=(0,i.useState)(),[p,u]=(0,i.useState)(JSON.stringify(e.config||"")),[g,f]=(0,i.useState)("");return(0,i.useEffect)(()=>{if(!t.current)return;let{className:s,style:n,height:i,sdkReady:a,config:c,...v}=e;if(o(s||""),l(n||{}),d(i),h&&g===JSON.stringify(v)){if(p===JSON.stringify(c))return;u(JSON.stringify(c)),"string"==typeof c?fetch(c).then(e=>e.json()).then(e=>{h?.setConfig(e)}):c&&h.setConfig(c)}else f(JSON.stringify(v)),h?.destroy(),(0,r.T)(t.current,{config:c,...v}).then(e=>{m(e),"function"==typeof a&&a(e)})},[e]),(0,i.useEffect)(()=>()=>{h?.destroy()},[]),(0,n.jsx)("div",{ref:t,className:s,style:a,"data-height":c})}var l=s("1858"),c=s("3262"),d=s("1705"),h=s("7645"),m=s("8168"),p=s("8228"),u=s("5050");function g(e){let[t,s]=(0,i.useState)(e.js),[o,r]=(0,i.useState)(e.ts),[a,l]=(0,i.useState)(e.react),[g,f]=(0,i.useState)(e.vue),[v,y]=(0,i.useState)(e.svelte),j="3.7rem",[x,b]=(0,i.useState)(!0),[w,C]=(0,i.useState)(j),S=(0,i.useRef)(null),L=()=>{setTimeout(()=>{C(`calc(${S.current.offsetHeight}px + ${j})`)},5),setTimeout(()=>{C(`calc(${S.current.offsetHeight}px + ${j})`)},255)};return(0,i.useEffect)(()=>{if(c.Z.canUseDOM){let e=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"js";try{return window.prettier?.format(e,{parser:"html"===t?"html":"babel",plugins:window.prettierPlugins})}catch{return e}};s(e(t,"js")),r(e(o,"ts")),l(e(a,"jsx")),f(e(g,"html")),y(e(v,"html"))}},[]),(0,n.jsxs)("details",{className:`alert alert--info ${u.Z.details} ${p.Z.details}`,"data-collapsed":x,style:{height:x?j:w,overflow:"hidden",willChange:"height",transition:`height ${x?"250ms":"265ms"} ease-in-out 0s`,margin:"1em 0"},children:[(0,n.jsx)("summary",{onClick:()=>{b(!x),L()},children:"show code"}),(0,n.jsx)("div",{ref:S,style:{display:"block",overflow:"hidden"},children:(0,n.jsx)("div",{className:u.Z.collapsibleContent,children:(0,n.jsxs)(m.Z,{groupId:"sdk-code",children:[(0,n.jsx)(h.Z,{value:"js",label:"JS",attributes:{onMouseDown:L},children:(0,n.jsx)(d.Z,{language:"js",children:t})}),(0,n.jsx)(h.Z,{value:"ts",label:"TS",attributes:{onMouseDown:L},children:(0,n.jsx)(d.Z,{language:"ts",children:o})}),(0,n.jsx)(h.Z,{value:"react",label:"React",attributes:{onMouseDown:L},children:(0,n.jsx)(d.Z,{language:"jsx",children:a})}),(0,n.jsx)(h.Z,{value:"vue",label:"Vue",attributes:{onMouseDown:L},children:(0,n.jsx)(d.Z,{language:"html",children:g})}),(0,n.jsx)(h.Z,{value:"svelte",label:"Svelte",attributes:{onMouseDown:L},children:(0,n.jsx)(d.Z,{language:"html",children:v})})]})})})]})}function f(e){let{className:t,style:s,showCode:i,height:r,...c}=e,{colorMode:d}=(0,o.I)(),h=e=>JSON.stringify(e,null,2),m=`
import { createPlayground } from 'livecodes';
const options = ${h(c)};
createPlayground('#container', options);
`.trimStart(),p=`
import { createPlayground, type EmbedOptions } from 'livecodes';
const options: EmbedOptions = ${h(c)};
createPlayground('#container', options);
`.trimStart(),u=`
import LiveCodes from 'livecodes/react';
export default function App() {
const options = ${h(c)};
return (