Commit Graph

31 Commits

Author SHA1 Message Date
Kartik Agaram 4a943d4ed3 5001 - drop the :(scenario) DSL
I've been saying for a while[1][2][3] that adding extra abstractions makes
things harder for newcomers, and adding new notations doubly so. And then
I notice this DSL in my own backyard. Makes me feel like a hypocrite.

[1] https://news.ycombinator.com/item?id=13565743#13570092
[2] https://lobste.rs/s/to8wpr/configuration_files_are_canary_warning
[3] https://lobste.rs/s/mdmcdi/little_languages_by_jon_bentley_1986#c_3miuf2

The implementation of the DSL was also highly hacky:

a) It was happening in the tangle/ tool, but was utterly unrelated to tangling
layers.

b) There were several persnickety constraints on the different kinds of
lines and the specific order they were expected in. I kept finding bugs
where the translator would silently do the wrong thing. Or the error messages
sucked, and readers may be stuck looking at the generated code to figure
out what happened. Fixing error messages would require a lot more code,
which is one of my arguments against DSLs in the first place: they may
be easy to implement, but they're hard to design to go with the grain of
the underlying platform. They require lots of iteration. Is that effort
worth prioritizing in this project?

On the other hand, the DSL did make at least some readers' life easier,
the ones who weren't immediately put off by having to learn a strange syntax.
There were fewer quotes to parse, fewer backslash escapes.

Anyway, since there are also people who dislike having to put up with strange
syntaxes, we'll call that consideration a wash and tear this DSL out.

---

This commit was sheer drudgery. Hopefully it won't need to be redone with
a new DSL because I grow sick of backslashes.
2019-03-12 19:14:12 -07:00
Kartik Agaram c442a5ad80 4987 - support `browse_trace` tool in SubX
I've extracted it into a separate binary, independent of my Mu prototype.

I also cleaned up my tracing layer to be a little nicer. Major improvements:

- Realized that incremental tracing really ought to be the default.
  And to minimize printing traces to screen.

- Finally figured out how to combine layers and call stack frames in a
  single dimension of depth. The answer: optimize for the experience of
  `browse_trace`. Instructions occupy a range of depths based on their call
  stack frame, and minor details of an instruction lie one level deeper
  in each case.

Other than that, I spent some time adjusting levels everywhere to make
`browse_trace` useful.
2019-02-25 01:50:53 -08:00
Kartik Agaram 23d3a02226 4266 - space for alloc-id in heap allocations
This has taken me almost 6 weeks :(
2018-06-24 09:18:20 -07:00
Kartik Agaram ce9b2b0515 4258 - undo 4257 2018-06-15 22:16:09 -07:00
Kartik Agaram 0edd9b9fc6 4257 - abortive attempt at safe fat pointers
I've been working on this slowly over several weeks, but it's too hard
to support 0 as the null value for addresses. I constantly have to add
exceptions for scalar value corresponding to an address type (now
occupying 2 locations). The final straw is the test for 'reload':

  x:num <- reload text

'reload' returns an address. But there's no way to know that for
arbitrary instructions.

New plan: let's put this off for a bit and first create support for
literals. Then use 'null' instead of '0' for addresses everywhere. Then
it'll be easy to just change what 'null' means.
2018-06-15 22:12:03 -07:00
Kartik K. Agaram acce384bcc 4179 - experiment: rip out memory reclamation
I have a plan for a way to avoid use-after-free errors without all the
overheads of maintaining refcounts. Has the nice side-effect of
requiring manual memory management. The Mu way is to leak memory by
default and build tools to help decide when and where to expend effort
plugging memory leaks. Arguably programs should be distributed with
summaries of their resource use characteristics.

Eliminating refcount maintenance reduces time to run tests by 30% for
`mu edit`:

              this commit                 parent
  mu test:         3.9s                        4.5s
  mu test edit:  2:38                        3:48

Open questions:
  - making reclamation easier; some sort of support for destructors
  - reclaiming local scopes (which are allocated on the heap)
    - should we support automatically reclaiming allocations inside them?
2018-01-03 00:44:09 -08:00
Kartik K. Agaram a89c1bed26 4104
Stop hardcoding Max_depth everywhere; we had a default value for a
reason but then we forgot all about it.
2017-11-03 01:50:46 -07:00
Kartik K. Agaram aa3d29a566 3668 - $read a word, stopping at whitespace
Useful for programming contests like https://halite.io

Doesn't suffer from C++'s usual buffered gotchas: it'll skip leading
whitespace. Slow, though. Can be speeded up, though.

- 20 minutes later
But what's the point? Typewriter mode is actually harder to test than
'raw' console mode. Writing Mu programs in typewriter mode is just going
to encourage us all to slack off on writing tests.
2016-11-11 23:04:01 -08:00
Kartik K. Agaram 1211a3ab30 3643
Standardize on calling literate waypoints "Special-cases" rather than
"Cases". Invariably there's a default path already present.
2016-11-07 09:10:48 -08:00
Kartik K. Agaram ef69c56c82 3608 - concurrent writes to fake file system 2016-10-29 17:06:48 -07:00
Kartik K. Agaram 66abe7c1bd 3539
Always check if next_word() returned an empty string (if it hit eof).

Thanks Rebecca Allard for running into a crash when a .mu file ends with
'{' (without a following newline).

Open question: how to express the constraint that next_word() should
always check if its result is empty? Can *any* type system do that?!
Even the usual constraint that we must use a result isn't iron-clad: you
could save the result in a variable but then ignore it. Unless you go to
Go's extraordinary lengths of considering any dead code an error.
2016-10-21 01:13:27 -07:00
Kartik K. Agaram 6c96a437ce 3522 2016-10-19 22:10:35 -07:00
Kartik K. Agaram 9ed95defa5 3505 2016-10-15 23:56:30 -07:00
Kartik K. Agaram 0893d65e27 3504 2016-10-15 23:55:21 -07:00
Kartik K. Agaram dd995c6174 3503
Undo commit 3500; turns out we need the duplicate scenario names for
good test failure messages.
2016-10-15 22:16:30 -07:00
Kartik K. Agaram 30c90fc4c7 3502
Better implementation of commit 3445: not requiring types for special
variables in scenarios. It turned out that it wasn't working anytime we
needed to call 'get' on a special variable inside a scenario. After
moving that work to an earlier transform we can now use 'filesystem'
without a type inside scenarios.
2016-10-15 21:12:30 -07:00
Kartik K. Agaram f510af3bae 3500 2016-10-15 20:57:43 -07:00
Kartik K. Agaram c594062cba 3438 2016-10-04 09:32:26 -07:00
Kartik K. Agaram a0331a9b0e 3390 2016-09-17 13:00:39 -07:00
Kartik K. Agaram 760f683f27 3389 2016-09-17 12:55:10 -07:00
Kartik K. Agaram 08f4628e8b 3379
Can't use type abbreviations inside 'memory-should-contain'.
2016-09-17 00:31:55 -07:00
Kartik K. Agaram d559f68b2f 3377 2016-09-17 00:12:08 -07:00
Kartik K. Agaram 78c5020531 3374 2016-09-16 23:57:55 -07:00
Kartik K. Agaram 5f05e954ee 3273
Undo 3272. The trouble with creating a new section for constants is that
there's no good place to order it since constants can be initialized
using globals as well as vice versa. And I don't want to add constraints
disallowing either side.

Instead, a new plan: always declare constants in the Globals section
using 'extern const' rather than just 'const', since otherwise constants
implicitly have internal linkage (http://stackoverflow.com/questions/14894698/why-does-extern-const-int-n-not-work-as-expected)
2016-08-28 18:37:57 -07:00
Kartik K. Agaram c7fde8d4e4 3272
Move global constants into their own section since we seem to be having
trouble linking in 'extern const' variables when manually cleaving mu.cc
into separate compilation units.
2016-08-28 17:08:01 -07:00
Kartik K. Agaram 7fd010710c 3259
Prefer preincrement operators wherever possible. Old versions of
compilers used to be better at optimizing them. Even if we don't care
about performance it's useful to make unary operators look like unary
operators wherever possible, and to distinguish the 'statement form'
which doesn't care about the value of the expression from the
postincrement which usually increments as a side-effect in some larger
computation (and so is worth avoiding except for some common idioms, or
perhaps even there).
2016-08-26 13:40:19 -07:00
Kartik K. Agaram 0230a6cc0b 3256
Bugfix in filesystem creation. I'm sure there are other fake-filesystem
bugs.
2016-08-26 11:27:13 -07:00
Kartik K. Agaram f40137f132 3239 2016-08-21 08:38:20 -07:00
Kartik K. Agaram 3369875ccd 3233 - change how Mu escapes strings
Thanks Sam Putman for helping think through this idea.

When you encounter a backslash, strip it out and pass through any
following run of backslashes. If we 'escaped' a single following
character like C, then the character '\' would be the same as:

  '\\' escaped once
  '\\\\' escaped twice
  '\\\\\\\\' escaped thrice (8 backslashes)

..and so on, the number of backslashes doubling each time. Instead, our
approach is to make the character '\' the same as:

  '\\' escaped once
  '\\\' escaped twice
  '\\\\' escaped thrice

..and so on, the number of backslashes merely increasing by one each
time.

This approach only works as long as backslashes aren't also overloaded
to create special characters. So Mu doesn't follow C's approach of
overloading backslashes both to escape quote characters and also as a
notation for unprintable characters like '\n'.
2016-08-20 19:44:07 -07:00
Kartik K. Agaram 18261f194d 3232
Support pipe characters in fake files. Still super ugly, though.
2016-08-20 18:51:35 -07:00
Kartik K. Agaram bc98ddb2b6 3229 - fake file systems using 'assume-filesystem'
Built with Stephen Malina.
2016-08-20 17:51:58 -07:00