about summary refs log tree commit diff stats
path: root/034address.cc
Commit message (Collapse)AuthorAgeFilesLines
* 3635 - show the array variant of 'new' earlierKartik K. Agaram2016-11-061-4/+23
|
* 3634Kartik K. Agaram2016-11-061-0/+4
|
* 3633 - new nest of bugs in 'new'Kartik K. Agaram2016-11-061-6/+9
|
* 3631Kartik K. Agaram2016-11-061-0/+7
|
* 3556Kartik K. Agaram2016-10-221-1/+1
|
* 3522Kartik K. Agaram2016-10-191-2/+2
|
* 3515Kartik K. Agaram2016-10-181-7/+8
| | | | Bugfix: allow 'new' to be passed in type abbreviations.
* 3381Kartik K. Agaram2016-09-171-1/+1
|
* 3380Kartik K. Agaram2016-09-171-14/+14
| | | | | One more place we were missing expanding type abbreviations: inside container definitions.
* 3309Kartik K. Agaram2016-09-091-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rip out everything to fix one failing unit test (commit 3290; type abbreviations). This commit does several things at once that I couldn't come up with a clean way to unpack: A. It moves to a new representation for type trees without changing the actual definition of the `type_tree` struct. B. It adds unit tests for our type metadata precomputation, so that errors there show up early and in a simpler setting rather than dying when we try to load Mu code. C. It fixes a bug, guarding against infinite loops when precomputing metadata for recursive shape-shifting containers. To do this it uses a dumb way of comparing type_trees, comparing their string representations instead. That is likely incredibly inefficient. Perhaps due to C, this commit has made Mu incredibly slow. Running all tests for the core and the edit/ app now takes 6.5 minutes rather than 3.5 minutes. == more notes and details I've been struggling for the past week now to back out of a bad design decision, a premature optimization from the early days: storing atoms directly in the 'value' slot of a cons cell rather than creating a special 'atom' cons cell and storing it on the 'left' slot. In other words, if a cons cell looks like this: o / | \ left val right ..then the type_tree (a b c) used to look like this (before this commit): o | \ a o | \ b o | \ c null ..rather than like this 'classic' approach to s-expressions which never mixes val and right (which is what we now have): o / \ o o | / \ a o o | / \ b o null | c The old approach made several operations more complicated, most recently the act of replacing a (possibly atom/leaf) sub-tree with another. That was the final straw that got me to realize the contortions I was going through to save a few type_tree nodes (cons cells). Switching to the new approach was hard partly because I've been using the old approach for so long and type_tree manipulations had pervaded everything. Another issue I ran into was the realization that my layers were not cleanly separated. Key parts of early layers (precomputing type metadata) existed purely for far later ones (shape-shifting types). Layers I got repeatedly stuck at: 1. the transform for precomputing type sizes (layer 30) 2. type-checks on merge instructions (layer 31) 3. the transform for precomputing address offsets in types (layer 36) 4. replace operations in supporting shape-shifting recipes (layer 55) After much thrashing I finally noticed that it wasn't the entirety of these layers that was giving me trouble, but just the type metadata precomputation, which had bugs that weren't manifesting until 30 layers later. Or, worse, when loading .mu files before any tests had had a chance to run. A common failure mode was running into types at run time that I hadn't precomputed metadata for at transform time. Digging into these bugs got me to realize that what I had before wasn't really very good, but a half-assed heuristic approach that did a whole lot of extra work precomputing metadata for utterly meaningless types like `((address number) 3)` which just happened to be part of a larger type like `(array (address number) 3)`. So, I redid it all. I switched the representation of types (because the old representation made unit tests difficult to retrofit) and added unit tests to the metadata precomputation. I also made layer 30 only do the minimal metadata precomputation it needs for the concepts introduced until then. In the process, I also made the precomputation more correct than before, and added hooks in the right place so that I could augment the logic when I introduced shape-shifting containers. == lessons learned There's several levels of hygiene when it comes to layers: 1. Every layer introduces precisely what it needs and in the simplest way possible. If I was building an app until just that layer, nothing would seem over-engineered. 2. Some layers are fore-shadowing features in future layers. Sometimes this is ok. For example, layer 10 foreshadows containers and arrays and so on without actually supporting them. That is a net win because it lets me lay out the core of Mu's data structures out in one place. But if the fore-shadowing gets too complex things get nasty. Not least because it can be hard to write unit tests for features before you provide the plumbing to visualize and manipulate them. 3. A layer is introducing features that are tested only in later layers. 4. A layer is introducing features with tests that are invalidated in later layers. (This I knew from early on to be an obviously horrendous idea.) Summary: avoid Level 2 (foreshadowing layers) as much as possible. Tolerate it indefinitely for small things where the code stays simple over time, but become strict again when things start to get more complex. Level 3 is mostly a net lose, but sometimes it can be expedient (a real case of the usually grossly over-applied term "technical debt"), and it's better than the conventional baseline of no layers and no scenarios. Just clean it up as soon as possible. Definitely avoid layer 4 at any time. == minor lessons Avoid unit tests for trivial things, write scenarios in context as much as possible. But within those margins unit tests are fine. Just introduce them before any scenarios (commit 3297). Reorganizing layers can be easy. Just merge layers for starters! Punt on resplitting them in some new way until you've gotten them to work. This is the wisdom of Refactoring: small steps. What made it hard was not wanting to merge *everything* between layer 30 and 55. The eventual insight was realizing I just need to move those two full-strength transforms and nothing else.
* 3273Kartik K. Agaram2016-08-281-1/+1
| | | | | | | | | | | 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)
* 3260Kartik K. Agaram2016-08-261-5/+5
| | | | | array length = number of elements array size = in locations
* 3259Kartik K. Agaram2016-08-261-2/+2
| | | | | | | | | | | 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).
* 3120Kartik K. Agaram2016-07-211-2/+2
| | | | | | | | Always show instruction before any transforms in error messages. This is likely going to make some errors unclear because they *need* to show the original instruction. But if we don't have tests for those situations did they ever really work?
* 3071Kartik K. Agaram2016-06-281-3/+0
|
* 3070Kartik K. Agaram2016-06-281-9/+14
| | | | | Extract out the implementation of 'allocate' so other instructions (ahem, deep-copy) can use it.
* 2990Kartik K. Agaram2016-05-201-4/+4
| | | | | | | | | | 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..
* 2971Kartik K. Agaram2016-05-171-2/+13
| | | | | | Long-overdue reorganization to support general 'dilated' reagents up front. This also allows me to move tests that are really about unrelated layers out of layers dealing with parsing.
* 2931 - be explicit about making copiesKartik K. Agaram2016-05-061-4/+4
|
* 2894Kartik K. Agaram2016-05-031-689/+20
| | | | | Reorganize the 'address' layer and split it up before we start greatly expanding them to manage refcounts in nested objects.
* 2893Kartik K. Agaram2016-05-031-0/+1032
00 render definitions in 2 columns' href='/akkartik/mu/commit/shell/global.mu?h=hlt&id=c811754807a8010afaad3bf13fad2f8b71889067'>c8117548 ^
542773df ^

c8117548 ^






c3069ab8 ^
0b055331 ^
11e8d83d ^


542773df ^
0b055331 ^

11e8d83d ^
542773df ^




c0db8068 ^
542773df ^

0b055331 ^
9269234e ^

dcb6a21a ^

995ff89c ^


c8117548 ^





0b055331 ^
995ff89c ^


c8117548 ^


0b055331 ^
995ff89c ^


c8117548 ^

c3069ab8 ^
542773df ^
c3069ab8 ^

ccadba5b ^

d6d28b8c ^

4bb826b4 ^
7de9d457 ^























4bb826b4 ^

5a066f8d ^

48522591 ^







542773df ^





5a066f8d ^






1c6b965a ^

139620e3 ^



542773df ^


139620e3 ^
542773df ^

139620e3 ^









f6808302 ^



139620e3 ^

48522591 ^

542773df ^


48522591 ^






f6808302 ^


cbf3de0f ^
f6808302 ^

995ff89c ^
b7e8c281 ^
cbf3de0f ^

0dda332c ^
48522591 ^

be9fa378 ^
7032a92c ^
7c8ad5a4 ^



7c8ad5a4 ^
3385febc ^
a5e1a220 ^
a5e1a220 ^
3385febc ^



542773df ^




a5e1a220 ^
7032a92c ^







be9fa378 ^

f6808302 ^



7032a92c ^

542773df ^























70919b45 ^
b9656ea8 ^
90748fa4 ^


b9656ea8 ^



90748fa4 ^


b9656ea8 ^

90748fa4 ^




b9656ea8 ^
70919b45 ^
400574f9 ^



70919b45 ^
400574f9 ^
70919b45 ^
400574f9 ^

70919b45 ^
770cac94 ^



70919b45 ^
770cac94 ^
70919b45 ^
770cac94 ^

b9656ea8 ^



90748fa4 ^

067fa9c7 ^
b9656ea8 ^

edae464d ^





















90748fa4 ^































a5e1a220 ^































c54b7e96 ^





















067fa9c7 ^
c54b7e96 ^

eb8260b2 ^
5b7f9387 ^
7c8ad5a4 ^


eb8260b2 ^
7c8ad5a4 ^
5b7f9387 ^

eb8260b2 ^
















5b7f9387 ^
b9c59a5f ^
31918612 ^

040b60bc ^
18c8e8c8 ^

040b60bc ^



3e32a1b8 ^
18c8e8c8 ^

0dda332c ^
040b60bc ^


















b9c59a5f ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582