Commit Graph

64 Commits

Author SHA1 Message Date
Kartik Agaram 85173b6220 4466
Why the heck was I using ints for OPEN/CLOSED in the first place?!
2018-08-03 23:08:09 -07:00
Kartik K. Agaram 090cad5c1b 4223 2018-03-14 00:59:41 -07:00
Kartik K. Agaram 7d07cd1de8 3987 2017-09-01 01:50:10 -07:00
Kartik K. Agaram ba1fb981f6 3811 2017-04-04 10:49:13 -07:00
Kartik K. Agaram e62aa7e305 3810
Stop naming 'jump' instructions in their errors since they're so often
rewritten from 'break' or 'loop' instructions.

Thanks Lakshman Swaminathan for running into this issue.
2017-04-04 00:18:44 -07:00
Kartik K. Agaram 95f2fe9626 3742 - move instruction.old_name to a later layer
The drawback of this is that we forget to initialize old_name when we
create instructions out of whole cloth in a few places. But this problem
already existed..
2017-02-06 23:44:46 -08:00
Kartik K. Agaram c8f2ff1392 3657 - better error message
Thanks Ella Couch for reporting this.
2016-11-10 10:34:16 -08:00
Kartik K. Agaram 9a81d7460f 3561 2016-10-22 16:56:07 -07:00
Kartik K. Agaram d3c120c1e2 3549
More consistent definitions for jump targets and waypoints.

1. A label is a word starting with something other than a letter or
digit or '$'.

2. A waypoint is a label that starts with '<' and ends with '>'. It has
no restrictions. A recipe can define any number of waypoints, and
recipes can have duplicate waypoints.

3. The special labels '{' and '}' can also be duplicated any number of
times in a recipe. The only constraint on them is that they have to
balance in any recipe. Every '{' must be followed by a matching '}'.

4. All other labels are 'jump targets'. You can't have duplicate jump
targets in a recipe; that would make jumps ambiguous.
2016-10-22 11:28:46 -07:00
Kartik K. Agaram 6c96a437ce 3522 2016-10-19 22:10:35 -07:00
Kartik K. Agaram 5813bcfc7d 3520
Drop a few debug prints. Hopefully now we need never duplicate trace
statements and can instead just dump them to screen.

I'll soon need the ability to selectively dump traces for a specific
label.
2016-10-18 10:44:40 -07:00
Kartik K. Agaram d52406ccd9 3381 2016-09-17 00:46:03 -07:00
Kartik K. Agaram 192d59d3bb 3380
One more place we were missing expanding type abbreviations: inside
container definitions.
2016-09-17 00:43:20 -07:00
Kartik K. Agaram 3259784417 3083 2016-07-01 22:34:50 -07:00
Kartik K. Agaram 9dcbec398c 2990
Standardize quotes around reagents in error messages.

I'm still sure there's issues. For example, the messages when
type-checking 'copy'. I'm not putting quotes around them because in
layer 60 I end up creating dilated reagents, and then it's a bit much to
have quotes and (two kinds of) brackets. But I'm sure I'm doing that
somewhere..
2016-05-20 22:11:34 -07:00
Kartik K. Agaram 3473c63ad9 2931 - be explicit about making copies 2016-05-06 00:46:39 -07:00
Kartik K. Agaram 5109e78fab 2874
Be more consistent that 'return' is the name of the instruction, and
'reply' just a synonym. Maybe I should take it out. It wouldn't affect
the recipe/ingredient terminology while I teach..
2016-04-27 15:37:09 -07:00
Kartik K. Agaram e765f9e74a 2873 - fix a bug in converting conditional returns
This was an interaction between two transforms. The first turned:

  return-if ...

into:

  jump-unless ..., 1:offset  # skip next instruction
  return ...

The second added an unconditional return at the end of the recipe if it
didn't already exist (so that functions always end with a return).
However, it was getting confused by the return instructions generated
above, which look unconditional but sometimes get skipped.

To fix this, conditional returns are now transformed into this:

  {
    break-unless ...
    return ...
  }

Since the final instruction is now no longer a reply (but rather the '}'
label), the second transform triggers and adds the unconditional return
after it.

This commit removes the final place marked 'BUG:' in the codebase
yesterday (see commit 2870).
2016-04-27 15:23:44 -07:00
Kartik K. Agaram b24eb4766a 2773 - switch to 'int'
This should eradicate the issue of 2771.
2016-03-13 20:26:47 -07:00
Kartik K. Agaram 1ead356219 2735 - define recipes using 'def'
I'm dropping all mention of 'recipe' terminology from the Readme. That
way I hope to avoid further bike-shedding discussions while I very
slowly decide on the right terminology with my students.

I could be smarter in my error messages and use 'recipe' when code uses
it and 'function' otherwise. But what about other words like ingredient?
It would all add complexity that I'm not yet sure is worthwhile. But I
do want separate experiences for veteran programmers reading about Mu on
github and for people learning programming using Mu.
2016-03-08 01:46:47 -08:00
Kartik K. Agaram 1b76245c63 2712 2016-02-26 13:04:55 -08:00
Kartik K. Agaram f51e9f63b4 2701 - turn some warnings into errors
I really have only one warning left: when somebody redefines a function.
I think I'm going to just turn that into an error as well and drop the
notion of warnings altogether. Anytime we find something wrong we stop
running the program. This is a place where hygiene is justified.
2016-02-25 07:46:56 -08:00
Kartik K. Agaram be45c43114 2685 2016-02-22 15:40:44 -08:00
Kartik K. Agaram c4e143d6ea 2681 - drop reagent types from reagent properties
All my attempts at staging this change failed with this humongous commit
that took all day and involved debugging three monstrous bugs. Two of
the bugs had to do with forgetting to check the type name in the
implementation of shape-shifting recipes. Bug #2 in particular would
cause core tests in layer 59 to fail -- only when I loaded up edit/! It
got me to just hack directly on mu.cc until I figured out the cause
(snapshot saved in mu.cc.modified). The problem turned out to be that I
accidentally saved a type ingredient in the Type table during
specialization. Now I know that that can be very bad.

I've checked the traces for any stray type numbers (rather than names).

I also found what might be a bug from last November (labeled TODO), but
we'll verify after this commit.
2016-02-21 20:40:06 -08:00
Kartik K. Agaram 343bc5359b 2677
Include type names in the type tree. Though we aren't using them yet.
2016-02-20 08:54:42 -08:00
Kartik K. Agaram 215365d427 2494
Some more structure to transforms, and flattening of dependencies
between them.
2015-11-28 22:17:47 -08:00
Kartik K. Agaram ebdf923d2d 2397
Fix that stray issue with a better phase ordering.
Another thing I'm not testing.
2015-11-08 14:04:46 -08:00
Kartik K. Agaram b2e4056d66 2383 - new concern: idempotence of transforms
I'd not paid any attention to it so far, but I need to do so from now
on.
2015-11-06 17:29:52 -08:00
Kartik K. Agaram 57d01f212c 2382
Starting to leave commented out prints again out of desperation.
2015-11-06 17:03:02 -08:00
Kartik K. Agaram 795f5244ab 2377 - stop using operator[] in map
I'm still seeing all sorts of failures in turning on layer 11 of edit/,
so I'm backing away and nailing down every culprit I run into. First up:
stop accidentally inserting empty objects into maps during lookups.

Commands run:
  $ sed -i 's/\(Recipe_ordinal\|Recipe\|Type_ordinal\|Type\|Memory\)\[\([^]]*\)\] = \(.*\);/put(\1, \2, \3);/' 0[1-9]*
  $ vi 075scenario_console.cc  # manually fix up Memory[Memory[CONSOLE]]
  $ sed -i 's/\(Memory\)\[\([^]]*\)\]/get_or_insert(\1, \2)/' 0[1-9]*
  $ sed -i 's/\(Recipe_ordinal\|Type_ordinal\)\[\([^]]*\)\]/get(\1, \2)/' 0[1-9]*
  $ sed -i 's/\(Recipe\|Type\)\[\([^]]*\)\]/get(\1, \2)/' 0[1-9]*

Now mu dies pretty quickly because of all the places I try to lookup a
missing value.
2015-11-06 11:17:25 -08:00
Kartik K. Agaram 356c966dc6 2372 2015-11-05 14:10:29 -08:00
Kartik K. Agaram 436b2b2eac 2360
More flailing around trying to come up with the right phase ordering.
I've tried to narrow down each transform's constraints wrt transforms in
previous layers.

One issue that keeps biting me is the Type map containing empty records
because of stray [] operations. That's gotta be important.
2015-11-04 23:44:46 -08:00
Kartik K. Agaram 5a4810855d 2358 - starting to tackle the phase ordering problem
A new externality is starting to make its presence felt.

Until I sort this out it's going to be hard to finish making duplex-list
generic.
2015-11-04 23:35:21 -08:00
Kartik K. Agaram 96369323aa 2349 2015-11-02 09:28:09 -08:00
Kartik K. Agaram f169287150 2348 2015-11-02 09:27:12 -08:00
Kartik K. Agaram e669248264 2321 - more preparations for static dispatch
Deduce operation id from name during transform rather than load, so that
earlier transforms have a chance to modify the name.
2015-10-29 17:15:09 -07:00
Kartik K. Agaram dd2e01e43e 2311 2015-10-29 11:56:10 -07:00
Kartik K. Agaram c6034af308 2277 - reagents now have a tree of types 2015-10-25 21:42:18 -07:00
Kartik K. Agaram 5f98a10cc7 2258 - separate warnings from errors
At the lowest level I'm reluctantly starting to see the need for errors
that stop the program in its tracks. Only way to avoid memory corruption
and security issues. But beyond that core I still want to be as lenient
as possible at higher levels of abstraction.
2015-10-06 22:15:45 -07:00
Kartik K. Agaram 4814bf94e7 2226 - standardize warning format
Always show recipe name where error occurred. But don't show internal
'interactive' name for sandboxes, that's just confusing.

What started out as warnings are now ossifying into errors that halt all
execution. Is this how things went with C and Unix as well?
2015-10-01 13:13:10 -07:00
Kartik K. Agaram 4082acd24f 2199 - stop printing numbers in scientific notation
Turns out the default format for printing floating point numbers is
neither 'scientific' nor 'fixed' even though those are the only two
options offered. Reading the C++ standard I found out that the default
(modulo locale changes) is basically the same as the printf "%g" format.
And "%g" is basically the shorter of:
  a) %f with trailing zeros trimmed
  b) %e
So we'll just do %f and trim trailing zeros.
2015-09-14 23:37:12 -07:00
Kartik K. Agaram e2f9979e5c 2137 2015-09-03 18:58:08 -07:00
Kartik K. Agaram 6c1376f830 2095
Finally terminate the experiment of keeping debug prints around. I'm
also going to give up on maintaining counts.

What we really need is two kinds of tracing:
  a) For tests, just the domain-specific facts, organized by labels.
  b) For debugging, just transient dumps to stdout.
b) only works if stdout is clean by default.

Hmm, I think this means 'stash' should be the transient kind of trace.
2015-08-28 23:25:21 -07:00
Kartik K. Agaram e85cb85b68 2075
Thanks Caleb Couch for bugfixes 2072-2075.
2015-08-24 20:25:37 -07:00
Kartik K. Agaram a2a0e711af 2043
Traces were changing based on whether I was loading a .mu file with
'main' or not.
2015-08-20 15:41:18 -07:00
Kartik K. Agaram 051c47384e 1962
Standardize test names.
2015-08-09 12:26:31 -07:00
Kartik K. Agaram bc64369276 1868 - start using naked literals everywhere
First step to reducing typing burden. Next step: inferring types.
2015-07-28 14:33:22 -07:00
Kartik K. Agaram e83602d391 1847 2015-07-25 14:19:16 -07:00
Kartik K. Agaram 35064671ef 1844 - explicitly end each trace line
More verbose, but it saves trouble when debugging; there's never
something you thought should be traced but just never came out the other
end.

Also got rid of fatal errors entirely. Everything's a warning now, and
code after a warning isn't guaranteed to run.
2015-07-25 00:02:20 -07:00
Kartik K. Agaram 4ce90b39d0 1837
Don't die on unbalanced '{'.
I won't bother adding more tests for warnings. Suffice it to say that we
need to gradually eliminate all asserts that check for illegal mu code.
2015-07-24 18:30:02 -07:00