Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[on hold] Add Minetest #5

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft

Conversation

dnchu
Copy link

@dnchu dnchu commented Jun 2, 2020

Question(s):

  • Any plans for "class" inheritance?
  • What is the proper way to use unions and nil?
  • Is it possible to mark a parameter as "non-nil"?

Here is some code that shows some of the weird behavior I get:

function dofile(filename: string)
	...
end
local s: string | nil = somevalue

dofile(s) -- error

if not s is nil then
	dofile(s) -- ok
end

if s is nil then
	dofile(s) -- ok
end

if s then
	dofile(s) -- error
end
if not s then
	return
end

dofile(s) -- error
if s is nil then
	return
end

dofile(s) -- error
Answered questions
  • Is it possible to have an array of multiple types? (Yes, with tl 0.6.0) For example:

    local Image = record 
    	name: string
    end
    local images: {string | Image} = { "diamond_1.png", { name = "diamond_2.png" } }
  • Is it possible to allow constructors for records? (Not yet) For example:

    global ItemStack = record
    end
    
    function ItemStack()
    end

@hishamhm
Copy link
Member

hishamhm commented Jun 3, 2020

Is it possible to have an array of multiple types? For example:

In tl 0.6.0, just released, it is. :) (there was a bug which I fixed)

Is it possible to allow constructors for records? For example:

Not yet... the types have no knowledge of metatables at this point.

end

function setfenv(x: any, y: any) -- TODO
function setfenv(x: any, y: any) -- TODO: add to tl
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A quick heads-up: I'd rather not adding Lua 5.1-only functions to the Teal standard library definitions — that reminds me I might need to double-check the math library additions!

@hishamhm
Copy link
Member

hishamhm commented Jun 3, 2020

Any plans for "class" inheritance?

This is under consideration — discussion ongoing here: teal-language/tl#97 (see also this draft for a simpler variant: teal-language/tl#124 )

What is the proper way to use unions and nil?
Is it possible to mark a parameter as "non-nil"?

Not yet. Nil in Teal currently works the same way as in Lua: every variable may be nil, regardless of its type (unions or not). I talk a bit about the challenges involved there in my FOSDEM 2020 talk here: https://www.youtube.com/watch?v=HfnjUCRzRKU

@dnchu dnchu changed the title [work in progress] Add Minetest [on hold] Add Minetest Jun 9, 2020
@jordan4ibanez
Copy link

Hey I got something for you https://github.com/jordan4ibanez/forgotten-lands/blob/main/minetest.d.tl
Near line 2000 I start my own thing, I've tried my best with this, if there are any updates to it as I'm testing it out I'll keep you updated. Running through the API.md was quite scary haha.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants