From 34d94104686fdb6e3bc2573315291770cab37cf3 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Thu, 22 Feb 2024 00:29:23 -0600 Subject: Change types to lowercase; add todos --- eval.lua | 6 +++--- readme.txt | 17 +++++++++++++++-- types.lua | 13 +++++++------ 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/eval.lua b/eval.lua index cdf4612..185268f 100644 --- a/eval.lua +++ b/eval.lua @@ -10,7 +10,7 @@ local types = require("types") if not table.unpack then table.unpack = unpack end local function Env(inner, outer) - return setmetatable(inner, { __type = "Environment", __index = outer, }) + return setmetatable(inner, { __type = "environment", __index = outer, }) end local function Proc(params, body, env) @@ -20,7 +20,7 @@ local function Proc(params, body, env) env = env, } local mt = { - __type = "Procedure", + __type = "procedure", __call = function (self, ...) local inner = {} @@ -37,7 +37,7 @@ end function eval.eval (x, e) e = e or global - if types.lamtype(x) == "Symbol" then + if types.lamtype(x) == "symbol" then return e[x] elseif types.luatype(x) ~= "table" then return x diff --git a/readme.txt b/readme.txt index 169c948..fd11f09 100644 --- a/readme.txt +++ b/readme.txt @@ -20,8 +20,8 @@ you can set up a repl of lam to test it out: all of lua's math.* functions are available, as well as -- + -- * (more math functions to come!) +- +, *, /, - +- =, <, >, <=, >= - null? - number? - symbol? @@ -38,11 +38,24 @@ and special forms - define - lambda +plus, some special lam functions: + +- luatype (the lua types of a value) +- type (the lam type of the value) + lam limitations --------------- - lam just has numbers and operations on them - uh, and symbols. and lists. and lambdas and environments. +todo +---- + +- move schemestr from repl into pp and expand (lua/lam pp, etc) +- add more datatypes (strings, anyone?!) +- numeric tower (oof) (at least exact/inexact numbers) +- .... + --------------------------- contributions/help WELCOME! diff --git a/types.lua b/types.lua index dd105cf..d4c8d14 100644 --- a/types.lua +++ b/types.lua @@ -6,21 +6,22 @@ types.luatype = type function types.lamtype (x) if types.luatype(x) == "string" then - return "Symbol" + return "symbol" elseif types.luatype(x) == "number" then - return "Number" + return "number" elseif getmetatable(x) and getmetatable(x).__type then return getmetatable(x).__type elseif types.luatype(x) == "table" then - return "List" + return "list" else return types.luatype(x) end end -types["number?"] = function (x) return types.lamtype(x) == "Number" end -types["symbol?"] = function (x) return types.lamtype(x) == "Symbol" end -types["list?"] = function (x) return types.lamtype(x) == "List" end +types["number?"] = function (x) return types.lamtype(x) == "number" end +types["symbol?"] = function (x) return types.lamtype(x) == "symbol" end +types["list?"] = function (x) return types.lamtype(x) == "list" end +types["procedure?"] = function (x) return types.lamtype(x) == "procedure" end types["null?"] = function (x) return x == {} end --- -- cgit 1.4.1-21-gabe81