lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Tue, 4 Jun 2019 at 21:24, Sean Conner <sean@conman.org> wrote:
>
> It was thus said that the Great Dibyendu Majumdar once stated:
> >
> > But more interestingly suppose you have a user defined type where the
> > metatable has been registered. Suppose that the name under which you
> > have registered the metatable is 'Torch.Tensor'.
> >
> > Then you can write:
> >
> > local x: Torch.Tensor = ...
> > function Foo (x: Torch.Tensor)
> > end
>
>   Interesting.  Can you handle the case where the user defined type has more
> than just letters, digits and periods?  I ask because I also use colons in
> my user defined types,  such as:
>
>         org.conman.net:addr
>         org.conman.net:sock
>

At the moment, no. Each period separated component must be a Name -
i.e. Lua identifier. So digits can appear within a name as per Lua
rules. But ':' is problematic as I allow cast operations such as:

local v = @Torch.Tensor SomeFuncReturningTensor()

You can imagine that ':' here would cause a problem - i.e. should it
be interpreted as a self operator?

The chosen syntax is easy to handle with Lua's existing lexer and
parser with some minor enhancements.

While this is off-topic it does bring again the issue of ambiguity when parsing.

Regards
Dibyendu