This commit is contained in:
Kartik K. Agaram 2017-11-03 18:01:59 -07:00
parent f78e5cb235
commit 504292f6f1
10 changed files with 14 additions and 15 deletions

View File

@ -5,9 +5,8 @@
//: Spaces are often called 'scopes' in other languages. Stack frames are a
//: limited form of space that can't outlive callers.
//:
//: Warning: messing with 'default-space' can corrupt memory. Don't do things
//: like initialize default-space with some other function's default-space.
//: Later we'll see how to chain spaces safely.
//: Warning: messing with 'default-space' can corrupt memory. Don't share
//: default-space between recipes. Later we'll see how to chain spaces safely.
//: Under the hood, a space is an array of locations in memory.
:(before "End Mu Types Initialization")

View File

@ -3,7 +3,7 @@
//: the variable in the chained/surrounding space. /space:2 looks up the
//: surrounding space of the surrounding space, etc.
//:
//: todo: warn on default-space abuse. default-space for one function should
//: todo: warn on default-space abuse. default-space for one recipe should
//: never come from another, otherwise memory will be corrupted.
:(scenario closure)

View File

@ -877,7 +877,7 @@ def main [
:(after "case _SYSTEM:")
if (Current_scenario) break;
//:: Warn if people use '_' manually in function names. They're reserved for internal use.
//:: Warn if people use '_' manually in recipe names. They're reserved for internal use.
:(scenario recipe_name_with_underscore)
% Hide_errors = true;

View File

@ -342,10 +342,10 @@ const recipe& best_variant(const instruction& inst, vector<recipe_ordinal>& cand
int min_index = 0;
for (int i = 0; i < SIZE(candidates); ++i) {
const recipe& candidate = get(Recipe, candidates.at(i));
// prefer functions without extra or missing ingredients or products
// prefer variants without extra or missing ingredients or products
int score = abs(SIZE(candidate.products)-SIZE(inst.products))
+ abs(SIZE(candidate.ingredients)-SIZE(inst.ingredients));
// prefer functions with non-address ingredients or products
// prefer variants with non-address ingredients or products
for (int j = 0; j < SIZE(candidate.ingredients); ++j) {
if (is_mu_address(candidate.ingredients.at(j)))
++score;

View File

@ -1,4 +1,4 @@
//: make some functions more friendly by trying to auto-convert their ingredients to text
//: make some recipes more friendly by trying to auto-convert their ingredients to text
:(scenarios transform)
:(scenario rewrite_stashes_to_text)

View File

@ -1,4 +1,4 @@
// A universal hash function that can handle objects of any type.
// Compute a hash for objects of any type.
//
// The way it's currently implemented, two objects will have the same hash if
// all their non-address fields (all the way down) expand to the same sequence

View File

@ -341,7 +341,7 @@ def f x:&:num -> y:num [
]
$error: 0
//: make sure we don't accidentally break on a function literal
//: make sure we don't accidentally break on a recipe literal
:(scenario jump_forbidden_on_recipe_literals)
% Hide_errors = true;
def foo [

View File

@ -4,7 +4,7 @@
//: scenario. 'screen-should-contain' can check unicode characters in the fake
//: screen
//: first make sure we don't mangle these functions in other transforms
//: first make sure we don't mangle these instructions in other transforms
:(before "End initialize_transform_rewrite_literal_string_to_text()")
recipes_taking_literal_strings.insert("screen-should-contain");
recipes_taking_literal_strings.insert("screen-should-contain-in-color");

View File

@ -4,7 +4,7 @@
//: scenario. Like with the fake screen, 'assume-console' transparently
//: supports unicode.
//: first make sure we don't mangle these functions in other transforms
//: first make sure we don't mangle this instruction in other transforms
:(before "End initialize_transform_rewrite_literal_string_to_text()")
recipes_taking_literal_strings.insert("assume-console");

View File

@ -1,6 +1,6 @@
//: Let's raise errors when students use real hardware in any functions
//: besides 'main'. Part of the goal is to teach them testing hygiene and
//: dependency injection.
//: Let's raise errors when students use real hardware in any recipes besides
//: 'main'. Part of the goal is to teach them testing hygiene and dependency
//: injection.
//:
//: This is easy to sidestep, it's for feedback rather than safety.