#Roblox introduces #Luau, its near-JIT interpreter for #Lua. The interp requires the Roblox engine. The language differs a little from regular Lua. https://roblox.github.io/luau/
if filehandle ~= nil then return filehandle end return false
This has been working okay, but I think
if filehandle ~= nil then return filehandle, true else return nil, false end
will more directly say what I mean. I need to read a little more to figure out which is more "idiomatic" for the language. (Or maybe ask @amic, who has used the language more than I have.)
This feels weird to me. Maybe because Lua is generally embedded inside of a game, where the script need not concern itself about saving its data to a file.
Good morning and #TZAG. I’m almost finished with today’s #YoCo ( #yogurt and #coffee ). Plans today include job searching, working on my toy project (part of learning #Lua; I’m also going to do another version of it to revive my !TclTk knowledge and possibly a 3rd version in another language), and removing some of the weeds growing in the yard.
I also need to visit the stores to see whether TP supplies have come in.
Time to go to bed. Exploration with #Lua again tonight. It is still mind-bending, but getting somewhat easier to grok. I suspect that I’ll be able to apply this to learning languages like #Squirrel and #Wren, which take inspiration from Lua.
As usual, if something seems to give unexpected results, look at the interaction with tables, which are dictionaries (associative arrays), but in some circumstances, more like real arrays or even classes & prototypes & objects.
Now watching some #PHP videos on the former #Lynda.com site ( now called #LinkedIn / #LockedOut Learning ) before I go back to the #Lua videos.
I had to take a time out from Lua because none of the (book and video) examples of "first class functions ... pass the function to that one" were working for me and I could not see why.
The odd thing is that the weird issues with scoping that I saw the past few days are gone today. Lua 5.1.5 on #Win10 1909 and Lua 5.2.4 on #Kubuntu 18.04, #Linux kernel 4.15
Going to have to read about the language’s history. I’m sure Lua is young enough to have been created after we learned that global vars should be avoided, so why global by default instead of only when expressly requested?
I’m bumbling through “Lua Quick Start Guide” and a couple of online #Lua introductions / tutorials. Usually at the same time. So when I want to go on to the next one, I want to type the equivalent of #Tcl’s
set variables [info vars]
So I can iterate through them and delete them (or set them to nil in Lua parlance). But in the resources I’ve looked at so far, that seems not to be a thing in the Lua world.
I’ve been doing some very introductory tutorials for #Lua. It seems pretty interesting. I don’t think it will displace #Tcl and #Python as my favorite scripting languages, but it could become the third in the set.
Seeing that tables (which are dictionaries—associative arrays—that can also act as regular arrays if numeric keys are used) are the only data structure, it sort of twists my mind into contortions trying to imagine how to structure certain kinds of data. That’s good, IMO, because history (took classes decades ago on BASIC, COBOL, Pascal, C, C++, Java, ...) predisposes me to look for arrays and records (or objects that encapsulate records) as the building blocks.
I’ve also downloaded (but not yet installed) #Erlang and #Elixir for Windows.
Found another old prepaid VISA gift card, but it's been so long that I can't read the expiration date (and therefore, cannot check to see how much is available to spend, if any). I'll take it with me the next time I visit a store and try to pay some or all of the price with it.
Now, I'm going to put away #Tcl, #Lua, and #Jsish, and go to bed. I took a couple of sips of sleep enhancer, so I'm hoping to get lots of rest tonight.