diff --git a/base64/base64.go b/base64/base64.go index 4adc12ade..04926a7bb 100644 --- a/base64/base64.go +++ b/base64/base64.go @@ -16,11 +16,10 @@ var base64DecodeString Proc = func(args []Object) Object { var base64Namespace = GLOBAL_ENV.EnsureNamespace(MakeSymbol("base64")) -func internBase64(name string, proc Proc) { - base64Namespace.Intern(MakeSymbol(name)).Value = proc -} - func init() { - base64Namespace.ResetMeta(MakeMeta("Implements base64 encoding as specified by RFC 4648.", "1.0")) - internBase64("decode-string", base64DecodeString) + base64Namespace.ResetMeta(MakeMeta(nil, "Implements base64 encoding as specified by RFC 4648.", "1.0")) + base64Namespace.InternVar("decode-string", base64DecodeString, + MakeMeta( + NewListFrom(NewVectorFrom(MakeSymbol("s"))), + "Returns the bytes represented by the base64 string s.", "1.0")) } diff --git a/core/environment.go b/core/environment.go index 5d33c0462..f0af5924c 100644 --- a/core/environment.go +++ b/core/environment.go @@ -24,7 +24,7 @@ func NewEnv(currentNs Symbol, stdout *os.File, stdin *os.File, stderr *os.File) Namespaces: make(map[*string]*Namespace), } res.CoreNamespace = res.EnsureNamespace(MakeSymbol("core")) - res.CoreNamespace.meta = MakeMeta("Core library of Joker.", "1.0") + res.CoreNamespace.meta = MakeMeta(nil, "Core library of Joker.", "1.0") res.ns = res.CoreNamespace.Intern(MakeSymbol("*ns*")) res.ns.Value = res.EnsureNamespace(currentNs) res.stdout = res.CoreNamespace.Intern(MakeSymbol("*out*")) @@ -36,10 +36,10 @@ func NewEnv(currentNs Symbol, stdout *os.File, stdin *os.File, stderr *os.File) res.file = res.CoreNamespace.Intern(MakeSymbol("*file*")) res.args = res.CoreNamespace.Intern(MakeSymbol("*command-line-args*")) args := EmptyVector - for _, arg := range os.Args { + for _, arg := range os.Args[1:] { args = args.Conjoin(String{S: arg}) } - if args.Count() > 1 { + if args.Count() > 0 { res.args.Value = args } else { res.args.Value = NIL diff --git a/core/object.go b/core/object.go index 18bc37dac..ed6b439b9 100644 --- a/core/object.go +++ b/core/object.go @@ -1329,8 +1329,11 @@ func IsSpecialSymbol(obj Object) bool { } } -func MakeMeta(docstring string, added string) Map { +func MakeMeta(arglists Seq, docstring string, added string) Map { res := EmptyArrayMap() + if arglists != nil { + res.Add(MakeKeyword("arglists"), arglists) + } res.Add(MakeKeyword("doc"), String{S: docstring}) res.Add(MakeKeyword("added"), String{S: added}) return res diff --git a/core/procs.go b/core/procs.go index 042b1e3e2..3386519d1 100644 --- a/core/procs.go +++ b/core/procs.go @@ -1304,7 +1304,7 @@ func intern(name string, proc Proc) { func init() { rand.Seed(time.Now().UnixNano()) GLOBAL_ENV.CoreNamespace.InternVar("*assert*", Bool{B: true}, - MakeMeta("When set to logical false, assert is a noop. Defaults to true.", "1.0")) + MakeMeta(nil, "When set to logical false, assert is a noop. Defaults to true.", "1.0")) intern("list**", procList) intern("cons*", procCons) diff --git a/docs/base64.html b/docs/base64.html index f34ca3dc1..4bd80808b 100644 --- a/docs/base64.html +++ b/docs/base64.html @@ -18,9 +18,10 @@

Index

  • decode-string

    Function - v -
    
    -  

    + v1.0 +
    (decode-string s)
    +
    +

    Returns the bytes represented by the base64 string s.

  • diff --git a/docs/json.html b/docs/json.html index f93d39453..0131618dd 100644 --- a/docs/json.html +++ b/docs/json.html @@ -18,9 +18,10 @@

    Index

  • read-string

    Function - v -
    
    -  

    + v1.0 +
    (read-string s)
    +
    +

    Parses the JSON-encoded data and return the result as a Joker value.

  • diff --git a/docs/os.html b/docs/os.html index 789e03b25..b2b4729e6 100644 --- a/docs/os.html +++ b/docs/os.html @@ -24,23 +24,26 @@

    Index

  • args

    Function - v -
    
    -  

    + v1.0 +
    (args)
    +
    +

    Returns a sequence of the command line arguments, starting with the program name (normally, joker).

  • env

    Function - v -
    
    -  

    + v1.0 +
    (env)
    +
    +

    Returns a map representing the environment.

  • sh

    Function - v -
    
    -  

    + v1.0 +
    (sh name & args)
    +
    +

    Executes the named program with the given arguments. Returns a map with the following keys:
    :success - whether or not the execution was successful,
    :out - string capturing stdout of the program,
    :err - string capturing stderr of the program.

  • diff --git a/docs/string.html b/docs/string.html index 94885dfa5..4499ba22f 100644 --- a/docs/string.html +++ b/docs/string.html @@ -36,51 +36,58 @@

    Index

  • ends-with?

    Function - v -
    
    -  

    + v1.0 +
    (ends-with? s substr)
    +
    +

    True if s ends with substr.

  • join

    Function - v -
    
    -  

    + v1.0 +
    (join separator coll)
    +
    +

    Returns a string of all elements in coll, as returned by (seq coll), separated by a separator.

  • pad-left

    Function - v -
    
    -  

    + v1.0 +
    (pad-left s pad n)
    +
    +

    Returns s padded with pad at the beginning to length n.

  • pad-right

    Function - v -
    
    -  

    + v1.0 +
    (pad-right s pad n)
    +
    +

    Returns s padded with pad at the end to length n.

  • replace

    Function - v -
    
    -  

    + v1.0 +
    (replace s old new)
    +
    +

    Replaces all instances of string old with string new in string s.

  • split

    Function - v -
    
    -  

    + v1.0 +
    (split s re)
    +
    +

    Splits string on a regular expression. Returns vector of the splits.

  • starts-with?

    Function - v -
    
    -  

    + v1.0 +
    (starts-with? s substr)
    +
    +

    True if s starts with substr.

  • diff --git a/json/json.go b/json/json.go index f31858b24..57332b9ed 100644 --- a/json/json.go +++ b/json/json.go @@ -44,11 +44,10 @@ var readString Proc = func(args []Object) Object { var jsonNamespace = GLOBAL_ENV.EnsureNamespace(MakeSymbol("json")) -func intern(name string, proc Proc) { - jsonNamespace.Intern(MakeSymbol(name)).Value = proc -} - func init() { - jsonNamespace.ResetMeta(MakeMeta("Implements encoding and decoding of JSON as defined in RFC 4627.", "1.0")) - intern("read-string", readString) + jsonNamespace.ResetMeta(MakeMeta(nil, "Implements encoding and decoding of JSON as defined in RFC 4627.", "1.0")) + jsonNamespace.InternVar("read-string", readString, + MakeMeta( + NewListFrom(NewVectorFrom(MakeSymbol("s"))), + "Parses the JSON-encoded data and return the result as a Joker value.", "1.0")) } diff --git a/os/os.go b/os/os.go index 29adec620..d76a452e1 100644 --- a/os/os.go +++ b/os/os.go @@ -62,12 +62,22 @@ var sh Proc = func(args []Object) Object { var osNamespace = GLOBAL_ENV.EnsureNamespace(MakeSymbol("os")) func intern(name string, proc Proc) { - osNamespace.ResetMeta(MakeMeta("Provides a platform-independent interface to operating system functionality.", "1.0")) osNamespace.Intern(MakeSymbol(name)).Value = proc } func init() { - intern("env", env) - intern("args", args) - intern("sh", sh) + osNamespace.ResetMeta(MakeMeta(nil, "Provides a platform-independent interface to operating system functionality.", "1.0")) + osNamespace.InternVar("env", env, MakeMeta(NewListFrom(EmptyVector), "Returns a map representing the environment.", "1.0")) + osNamespace.InternVar("args", args, + MakeMeta( + NewListFrom(EmptyVector), + "Returns a sequence of the command line arguments, starting with the program name (normally, joker).", "1.0")) + osNamespace.InternVar("sh", sh, + MakeMeta( + NewListFrom( + NewVectorFrom(MakeSymbol("name"), MakeSymbol("&"), MakeSymbol("args"))), + `Executes the named program with the given arguments. Returns a map with the following keys: + :success - whether or not the execution was successful, + :out - string capturing stdout of the program, + :err - string capturing stderr of the program.`, "1.0")) } diff --git a/string/string.go b/string/string.go index d05b25b19..b8116801f 100644 --- a/string/string.go +++ b/string/string.go @@ -92,12 +92,33 @@ var replace Proc = func(args []Object) Object { } func init() { - stringNamespace.ResetMeta(MakeMeta("Implements simple functions to manipulate strings.", "1.0")) - intern("pad-right", padRight) - intern("pad-left", padLeft) - intern("split", split) - intern("join", join) - intern("ends-with?", endsWith) - intern("starts-with?", startsWith) - intern("replace", replace) + stringNamespace.ResetMeta(MakeMeta(nil, "Implements simple functions to manipulate strings.", "1.0")) + stringNamespace.InternVar("pad-right", padRight, + MakeMeta( + NewListFrom(NewVectorFrom(MakeSymbol("s"), MakeSymbol("pad"), MakeSymbol("n"))), + "Returns s padded with pad at the end to length n.", "1.0")) + stringNamespace.InternVar("pad-left", padLeft, + MakeMeta( + NewListFrom(NewVectorFrom(MakeSymbol("s"), MakeSymbol("pad"), MakeSymbol("n"))), + "Returns s padded with pad at the beginning to length n.", "1.0")) + stringNamespace.InternVar("split", split, + MakeMeta( + NewListFrom(NewVectorFrom(MakeSymbol("s"), MakeSymbol("re"))), + "Splits string on a regular expression. Returns vector of the splits.", "1.0")) + stringNamespace.InternVar("join", join, + MakeMeta( + NewListFrom(NewVectorFrom(MakeSymbol("separator"), MakeSymbol("coll"))), + "Returns a string of all elements in coll, as returned by (seq coll), separated by a separator.", "1.0")) + stringNamespace.InternVar("ends-with?", endsWith, + MakeMeta( + NewListFrom(NewVectorFrom(MakeSymbol("s"), MakeSymbol("substr"))), + "True if s ends with substr.", "1.0")) + stringNamespace.InternVar("starts-with?", startsWith, + MakeMeta( + NewListFrom(NewVectorFrom(MakeSymbol("s"), MakeSymbol("substr"))), + "True if s starts with substr.", "1.0")) + stringNamespace.InternVar("replace", replace, + MakeMeta( + NewListFrom(NewVectorFrom(MakeSymbol("s"), MakeSymbol("old"), MakeSymbol("new"))), + "Replaces all instances of string old with string new in string s.", "1.0")) }