You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wonder, why all purely "abstract" types (listtuplemaparrayenum) can't be matched against concrete versions of them (e.g. list<int>tuple<string, int>map<int, string>array<int>enum<a, b>). Is there any reason for that? Currently it feels more like some magic:
l={1,'x'}if(l ?< list)io.writeln('do match',std.about(l))elseio.writeln('do NOT match',std.about(l))#t = (1,'x')#if ( t ?< tuple )# io.writeln('do match', std.about(t))#else# io.writeln('do NOT match', std.about(t))m={1->'x'}if(m ?< map)io.writeln('do match',std.about(m))elseio.writeln('do NOT match',std.about(m))m2={1=>'x'}if(m2 ?< map)io.writeln('do match',std.about(m2))elseio.writeln('do NOT match',std.about(m2))a=array{1,2}if(a ?< array)io.writeln('do match',std.about(a))elseio.writeln('do NOT match',std.about(a))e=(enum<x,y>)$x
if(e ?< enum)io.writeln('do match',std.about(e))elseio.writeln('do NOT match',std.about(e))
gives:
do match list<any>[0x7dad30]:list<any>
do NOT match map<int,string>[0x7daf20]:map<int,string>
do NOT match map<int,string>[0x810f90]:map<int,string>
do NOT match array<int>[0x7f4bf0]:array<int>
do match enum<x,y>[0x7b4200]:enum<x,y>
and with the commented lines uncommented:
[[ERROR]] in file "/home/test/test.dao":
At line 8 : Invalid expression --- " t ?< tuple ";
At line 8 : Invalid expression --- " t ?< tuple ) ";
At line 8 : Symbol not defined --- " tuple ";
This error with tuple is quite surprising, because x: tuple<int> = (5,) and x: tuple = (5,) works like a charm.
The text was updated successfully, but these errors were encountered:
I wonder, why all purely "abstract" types (
list
tuple
map
array
enum
) can't be matched against concrete versions of them (e.g.list<int>
tuple<string, int>
map<int, string>
array<int>
enum<a, b>
). Is there any reason for that? Currently it feels more like some magic:gives:
and with the commented lines uncommented:
This error with tuple is quite surprising, because
x: tuple<int> = (5,)
andx: tuple = (5,)
works like a charm.The text was updated successfully, but these errors were encountered: