I tried your example in DrRacket and it does not nest :(
I think it's possible, but I'm not sure. The reader in #2dcond is already isolating the cell, for example in this monstousity:
#lang 2d racket
(require 2d/cond)
(define (same? a b)
#2dcond
╔═════════════╦═══════════════════════╦═════════════╗
║ ║ (pair? a) ║ (number? a) ║
╠═════════════╬═══════════════════════╬═════════════╣
║ (pair? b) ║ " .║ 333 ║
║ ║. " ║ ║
╠═════════════╬═══════════════════════╬═════════════╣
║ (number? b) ║ 444 ║ (= a b) ║
╚═════════════╩═══════════════════════╩═════════════╝)
(same? '(1) '(2)) ;==> " . \n . "
(same? 5 '(2)) ;==> 333
There is a string that start in the fist line of the central cell and ends in the second line of that cell. The string does not include the 333 that is "between" the two double quotes, but it includes some fake spaces (?!). You can even replace the 333 with "333" and each string only get characters inside their own cell (and fake spaces).
About the default value, I prefer the empty cell for clarity. The default is to raise an error. In some expressions in Racket the dafault is (void) and in other to raise an error. Both camps have strong opinions. I think the comunity is moving slowly to error, but old stuff have to keep the old behavior for backward compatibility.
I wonder how hard it is to fix that it doesn't nest? Clearly, the algorithm pulls out a multi-line piece of code out of a boxed cell. The #2dcond is a piece of multi-line syntax. Maybe it's one-liner fix in the code. Unless something like the box recognition logic is confused by nested box material.
Sorry for the long delay, but I needed some time to think about it and to draw it.
The problem are free floating cells. (I don't know if they have a technical name.)
For example
#lang 2d racket
(require 2d/cond)
(define (myfun a b c d e f)
#2dcond
╔═══╦═══╦═══════╦═══╗
║ ║ a ║ b ║ c ║
╠═══╬═══╩═══════╩═══╣
║ d ║ 0 ║
╠═══╣ ╔═══════╗ ║
║ e ║ ║ 1 ║ ║
╠═══╣ ╚═══════╝ ║
║ f ║ ║
╚═══╩═══════════════╝)
(myfun #true #f #f #true #f #f) ;==> 0
(myfun #f #true #f #f #true #f) ;==> 1
In a variant with " " to make a sring, you get
#lang 2d racket
(require 2d/cond)
(define (myfun a b c d e f)
#2dcond
╔═══╦═══╦═══════╦═══╗
║ ║ a ║ b ║ c ║
╠═══╬═══╩═══════╩═══╣
║ d ║ " ║
╠═══╣ ╔═══════╗ ║
║ e ║ ║ 1 ║ ║
╠═══╣ ╚═══════╝ ║
║ f ║ " ║
╚═══╩═══════════════╝)
(myfun #true #f #f #true #f #f) ;==> " \n \n \n \n
(myfun #f #true #f #f #true #f) ;==> 1
Should the table parse first the folating cell in the middel or should the " " include the cell as part of the string.
Now
#lang 2d racket
(require 2d/cond)
; res, it's an error
(define (myfun a b c d e f)
#2dcond
╔═══╦═══╦═══════╦═══╗
║ ║ a ║ b ║ c ║
╠═══╬═══╩═══════╩═══╣
║ d ║ #2dcond ║
╠═══╣ ╔═══════╗ ║
║ e ║ ║ 1 ║ ║
╠═══╣ ╚═══════╝ ║
║ f ║ ║
╚═══╩═══════════════╝)
(myfun #true #f #f #true #f #f) ;==> ???
(myfun #f #true #f #f #true #f) ;==> ???
This is an error, but imagine that the middel cell has the correct shape. I like the idea of nesting #2dcond but it looks difficult to make a consistet rule when there are floating cells. :(
I think it's possible, but I'm not sure. The reader in #2dcond is already isolating the cell, for example in this monstousity:
There is a string that start in the fist line of the central cell and ends in the second line of that cell. The string does not include the 333 that is "between" the two double quotes, but it includes some fake spaces (?!). You can even replace the 333 with "333" and each string only get characters inside their own cell (and fake spaces).About the default value, I prefer the empty cell for clarity. The default is to raise an error. In some expressions in Racket the dafault is (void) and in other to raise an error. Both camps have strong opinions. I think the comunity is moving slowly to error, but old stuff have to keep the old behavior for backward compatibility.