blaze / datashape

Language defining a data description protocol
BSD 2-Clause "Simplified" License
183 stars 65 forks source link

option/questionmark equivalence #206

Open skrah opened 8 years ago

skrah commented 8 years ago

I think this should probably be rejected by the parser:

parse("A * option[?int32]", symtable) dshape("A * ??int32")

This one is rejected:

parse("A * ??int32", symtable) Traceback (most recent call last): [...] datashape.error.DataShapeSyntaxError: Expected a dim or a dtype

I'm not sure if option/questionmark should be exactly equivalent.

llllllllll commented 8 years ago

I think the real bug here is that ??A is rejected. imho this should be allowed.

skrah commented 8 years ago

Theoretically it should be allowed -- for example the ML type system allows it, too:

Poly/ML 5.2 Release

SOME (SOME 10); val it = SOME (SOME 10) : int option option

But it probably doesn't occur in practice. dynd-python explicitly disallows it:

Python 3.5.1 |Continuum Analytics, Inc.| (default, Dec 7 2015, 11:16:01) [GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux Type "help", "copyright", "credits" or "license" for more information.

from dynd import nd, ndt a = nd.empty("A * option[?int32]") Traceback (most recent call last): File "", line 1, in File "dynd/nd/array.pyx", line 800, in dynd.nd.array.empty (/home/travis/build/libdynd/dynd-python/build/temp.linux-x86_64-3.5/array.cxx:7592) File "dynd/ndt/type.pyx", line 122, in dynd.ndt.type.type.cinit (/home/travis/build/libdynd/dynd-python/build/temp.linux-x86_64-3.5/type.cxx:1565) TypeError: Cannot construct an option type out of ?int32, it is already an option type