Skip to content

Instantly share code, notes, and snippets.

@lucasbuchala
Created May 16, 2018 19:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucasbuchala/704738bf9c875116fe713f7dd46192ff to your computer and use it in GitHub Desktop.
Save lucasbuchala/704738bf9c875116fe713f7dd46192ff to your computer and use it in GitHub Desktop.

Consider this snippet:

# multi f(IntStr)     { 'ok 1' };  multi f(42)     { 'ok 2' }  # line (1)
# multi f(NumStr)     { 'ok 3' };  multi f(2e5)    { 'ok 4' }  # line (2)
# multi f(RatStr)     { 'ok 5' };  multi f(<1/2>)  { 'ok 6' }  # line (3)
# multi f(ComplexStr) { 'ok 7' };  multi f(<1+2i>) { 'ok 8' }  # line (4)

multi f(|) { '?' }

.say for f(IntStr),     f(42);
.say for f(NumStr),     f(2e5);
.say for f(RatStr),     f(<1/2>);
.say for f(ComplexStr), f(<1+2i>);

With all lines (1) to (4) commented, the output is just "?". When each line (1) to (4) is uncommented separately, the output is the one shown in the table:

+------+-------+-------+-------+-------+
| ###  | [1]   | [2]   | [3]   | [4]   |
+------+-------+-------+-------+-------+
| ?    | ok 1  | ?     | ?     | ?     |
| ?    | ok 2  | ?     | ?     | ?     |
| ?    | ?     | ok 3  | ?     | ?     |
| ?    | ?     | ok 4  | ?     | ?     |
| ?    | ?     | ?     | ok 5  | ?     |
| ?    | ?     | ?     | ok 6  | ?     |
| ?    | ?     | ?     | ?     | ok 7  |
| ?    | ?     | ?     | ?     | ok 8  |
+------+-------+-------+-------+-------+

But if 2 or more lines are uncommented, no matter what subset of the lines, then this error happens:

===SORRY!===
Circularity detected in multi sub types for &f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment