Commit 1f269746 authored by Juergen Nickelsen's avatar Juergen Nickelsen
Browse files

made symbols a Builtin and did apropos in Lisp

parent 73b821ce
Loading
Loading
Loading
Loading
+4 −18
Original line number Diff line number Diff line
@@ -395,23 +395,9 @@ sub Bload {
        return load($fname, $noerror, $nomessage);
}

sub Bapropos {
        my ($re) = checkargs($_[0], ':S');
        $re = '.' if is_nil($re);
        my $result = $Nil;
        my $end;
        for my $sym (sort {symbol_name($a) cmp symbol_name($b)} all_symbols()) {
                if (symbol_name($sym) =~ /$re/) {
                        my $newpair = cons($sym, $Nil);
                        if ($end) {
                                rplacd($end, $newpair);
                                $end = $newpair;
                        } else {
                                $end = $result = $newpair;
                        }
                }
        }
        return $result;
sub Bsymbols {
        checkargs($_[0], '');
        return array2list(all_symbols);
}

sub Beq {
@@ -933,7 +919,7 @@ my @builtins = # [name, func, is_special, doc]
      "define an anonymous special form from ARGS and &rest BODY"],
     ["eq", \&Beq, 0,
      "return t if ARG1 and ARG2 are the same object, nil else"],
     ["apropos", \&Bapropos, 0, "return a list of symbols matching ARG"],
     ["symbols", \&Bsymbols, 0, "return a list of all symbols"],
     ["princ", \&Bprinc, 0, "print ARG to standard output without quoting"],
     ["princs", \&Bprincs, 0, "princ ARG to a string and return the string"],
     ["prin1", \&Bprin1, 0, "print ARG suitable for read"],
+4 −3
Original line number Diff line number Diff line
;; fundamental predefined Lisp functions
;(debug t)

(defun symbols ()
  "return a sorted list of all symbols"
  (apropos "."))
(defun apropos (match)
  (sort (filter #'(lambda (sym) (re-match match (symbol-name sym)))
                (symbols))
        #'string<))

(defun caar (pair)
  "return the car of the car of PAIR"
+6 −2
Original line number Diff line number Diff line
@@ -2,9 +2,13 @@

*: to do; @: in progress; #: blocked; +: done; -: rejected

  * do something sensible with (describe) for functions
  * environments and lexical scope

  * 031 and read errors
  * more of alists

  + do something sensible with (describe) for functions

  + 031 and read errors

  + command line options like lingo's -e -h -l -q