small changes before Fixing the macro bug

This commit is contained in:
Felix Brendel
2020-02-29 14:09:56 +01:00
parent 7c220ed9d6
commit 3b85873039
3 changed files with 11 additions and 8 deletions
+1 -1
View File
@@ -411,7 +411,7 @@ by the key 'from' and ends with the number defined in 'to'."
result) result)
(define (map fun seq) (define (map fun seq)
:doc "Takes a function and a sequence as arguments and returns a new "Takes a function and a sequence as arguments and returns a new
sequence which contains the results of using the first sequences sequence which contains the results of using the first sequences
elemens as argument to that function." elemens as argument to that function."
(if (null? seq) (if (null? seq)
+5 -6
View File
@@ -229,12 +229,10 @@ namespace Slime {
Lisp_Object_Type type = Memory::get_type(definee); Lisp_Object_Type type = Memory::get_type(definee);
switch (type) { switch (type) {
case Lisp_Object_Type::Symbol: { case Lisp_Object_Type::Symbol: {
// BUG(Felix): Defining with doc string crashes
if (form != Memory::nil) { if (form != Memory::nil) {
Lisp_Object* doc = thing; Lisp_Object* doc = thing;
try_void assert_type(doc, Lisp_Object_Type::String); try_void assert_type(doc, Lisp_Object_Type::String);
try_void assert_type(form, Lisp_Object_Type::Pair); try_void assert_type(form, Lisp_Object_Type::Pair);
form = form->value.pair.rest;
thing = form->value.pair.first; thing = form->value.pair.first;
try_void assert(form->value.pair.rest == Memory::nil); try_void assert(form->value.pair.rest == Memory::nil);
// TODO docs // TODO docs
@@ -1053,16 +1051,17 @@ namespace Slime {
} }
return Memory::t; return Memory::t;
}; };
define((print (:sep " ") (:end "\n") . things), "TODO") { define((print (:sep " ") (:end "\n") (:repr ()) . things), "TODO") {
profile_with_name("(print)"); profile_with_name("(print)");
fetch(sep, end, things); fetch(sep, end, repr, things);
if (things != Memory::nil) { if (things != Memory::nil) {
print(things->value.pair.first); bool print_repr = repr != Memory::nil;
print(things->value.pair.first, repr);
for_lisp_list(things->value.pair.rest) { for_lisp_list(things->value.pair.rest) {
print(sep); print(sep);
print(it); print(it, repr);
} }
} }
+5 -1
View File
@@ -304,7 +304,7 @@ namespace Slime {
} }
proc string_buider_to_string(Array_List<char*> string_builder) -> char* { proc string_buider_to_string(Array_List<char*> string_builder) -> char* {
int len = 1; size_t len = 1;
int idx = 0; int idx = 0;
for (auto str : string_builder) { for (auto str : string_builder) {
len += strlen(str); len += strlen(str);
@@ -479,6 +479,10 @@ namespace Slime {
return string_buider_to_string(string_builder); return string_buider_to_string(string_builder);
} }
default:
create_generic_error("A Lisp_Object of type-id %d cannot be converted to a string",
(int)(Memory::get_type(node)));
return nullptr;
} }
} }