[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: A question of type assertion
- From: Dibyendu Majumdar <mobile@...>
- Date: Mon, 9 Nov 2015 23:32:51 +0000
On 9 November 2015 at 23:09, Dibyendu Majumdar <email@example.com> wrote:
> On 9 November 2015 at 22:15, Coda Highland <firstname.lastname@example.org> wrote:
>>> Now here is a hypothetical question - if Lua had been statically typed
>>> language - what would the ideal expression be for this kind of type
>> Personally I'd go with asinteger() (or perhaps cast.integer(), to
>> limit the namespace pollution to a single keyword) so that the grammar
>> doesn't need modified, and then special-case the function invocation
>> as some kind of intrinsic instead of an actual function call.
> I have been thinking about the idea of intrinsics that the VM is aware
> of. Agree that doing it this way means that it behaves no different
> than if there were some functions that did the same thing.
Come to think of it actually it could be a noop function - i.e. the
function call would cause the code generator to insert type coercion
operations but then the VM would recognise the noop function and do
nothing. So I can imagine a function called cast() which is this magic
local i: integer = cast(x)
Would cause the code generator to emit TOINT opcode after calling the
function cast(). But the VM would not call any function at all as it
would recognize 'cast()' as noop.
Does this sound crazy?