uid / snapdown

Draw snapshot diagrams with plain text
MIT License
3 stars 0 forks source link

Crossed-out arrows and fields #5

Open dwhatley19 opened 3 years ago

dwhatley19 commented 3 years ago

In 6.031, many diagrams contain crossed-out elements, such as arrows and fields, and possibly entire nodes. These can be used to demonstrate the principles of mutability and reassignment. For example (http://web.mit.edu/6.031/www/sp20/classes/08-immutability/#@string_t_s):

image

These need to be supported by Snapdown.

dwhatley19 commented 3 years ago

Crossed-out arrows added via a5e2663, example: https://web.mit.edu/dwhatley/www/snapdown/web/production.html#a%20-%3E%20(String%20%22hello%22)%0Ab%20-x%3E%20a%0Ac%20-%3E%20(List%200%20-x%3E%20a)%0Ad%20-x%3E%20(Map%20a%20-%3E%20b)

Crossed-out fields are lower priority.

dwhatley19 commented 3 years ago

Ability to have one variable point to multiple values (i.e., when at least one pointer is crossed out) is done: https://web.mit.edu/dwhatley/www/snapdown/web/production.html#x%20-x%3E%20((String%20%22a%22))%0Ax%20-%3E%20((String%20%22b%22))%0Ax%20-x%3E%20((String%20%22c%22))

dwhatley19 commented 3 years ago

Ability to have multiple arrows (incl. crossed-out arrows) extending from a single array element is also done, pending possible layout tweaks: http://web.mit.edu/dwhatley/www/snapdown/web/production.html#%231%20-%3E%20%22abc%22%0A%231%20-x%3E%20%22def%22%0Aa%20-%3E%20%5B%231%2C%20%22ghi%22%5D

dwhatley19 commented 3 years ago

Crossed out variables and fields proposed syntax:

sb -> (StringBuilder ~"a"~ ~"ab"~ "abc")
tb -> sb
~tb2~ -> sb