RiscLua 8
Pages: 1 2
GavinWraith (26) 1563 posts |
A new version of RiscLua, 8.0, based on Lua 5.4.0(alpha), is available from the usual place . The default version uses VFP floats, so will not work on the Iyonix. However, you can modify it by dragging IYO.!rlua8 on top, to get a version that will, so long as you have !SharedLibs in !Boot.Resources, suitably loaded with all the nourishment that GCC-compiled software requires (see here ). Please tell me if it also works on a RiscPC. |
Matthew Phillips (473) 719 posts |
Thanks Gavin! |
GavinWraith (26) 1563 posts |
RiscLua 8 now updated to Lua 5.4.0 alpha release candidate 2. I have hit a snag in developing a Lua wimp library. On the wimp side of things there are now libraries catering for tasks, menus, iconbar and window templates, which seem to be functioning correctly. I have written a library for opening windows, but a simple test example that starts a task, loads a template and opens a window, has a nasty side-effect. It opens the window correctly but registers a segmentation fault . The error appears to originate in the garbage collector, in a function that switches the gc-mode to generational. As this is a new feature in Lua 5.4.0 and off the map for RISC OS, it is a bit worrying. It could be something in GCC’s Unixlib. It is most likely to be a senior moment of my own somewhere, but I lack tools to track down what is happening inside SWIs. |
Stephan Kleinert (2271) 70 posts |
Great work! Many thanks, Gavin! |
GavinWraith (26) 1563 posts |
I am pretty much convinced that the snag I hit is down to an as yet unidentified bug of my own. It is not in any of the material on my website. I compiled another version of the binaries in which dim med memory is not collectible as garbage but is simply malloc ed. But that appears to make no difference. What puzzles me is that the windows open as they should, and the error, which is raised by Lua, is caused when the task exits. This led me to think it might be related to memory clean up. The chief new feature of Lua 5.4.0 is a more sophisticated garbage collector. |
GavinWraith (26) 1563 posts |
Lua 5.40 (beta) is now out. The only syntactic change from alpha (which RiscLua 8 is based on) is that
is now
One of the innovations of version 5.40 is to-be-closed local variables. These trigger a closure metamethod when they go out of scope. When files are opened, for example, they have a closure metamethod automatically assigned, so that explicitly closing them in the program text can be avoided by the use of to-be-closed variables. Whether this is a good or bad programming practice is matter for debate elsewhere. This example for RiscLua 8 might amuse:
Here x has the value of an empty table, but with a tostring metamethod so that the print function treats it as hi, and a close metamethod that prints it. Because x goes out of scope when the program ends, and it is defined as a to-close variable, the program prints out hi. The point is, should I go through the rigmarole of upgrading RiscLua to keep up, as I used to? I am tempted to wait until Lua 5.40 goes out of beta. |
Rick Murray (539) 13806 posts |
Wow. There’s so much odd looking punctuation in Lua programs. Question for the clever (and Aldershot, I presume): has anybody managed to come up with a useful language that simply gives written statements (like short commands in English) without weird punctuation and codes? I can imagine there would be quite a challenge in translating how people think into how computers behave without ending up with something like the many existent programming languages… |
GavinWraith (26) 1563 posts |
This is a very good question. Lua (and Python, and … ) are all much more readable than Perl, which was the only scripting language around for some time. But they still have some way to go. Cobol also tried to be more friendly, at least to businessmen, perhaps. Have you ever seen any mathematical texts from more than 400 years ago? They took pages of confusing verbiage to express a single simple equation. The odd looking punctuation is there for compression, which, paradoxically perhaps, makes for greater intelligibility. So the afore-mentioned example could be described like this:
The braces after the word It is a question of what you are used to. Punctuation is definitely useful. In ancient times they had less. The idea of using blank spaces to separate words is comparatively recent, though some ancient writing systems did have a special symbol for it. It is just that in mathematics and programming there can be more punctuation than text. |
Steffen Huber (91) 1949 posts |
You mean something like Ada or Pascal or Modula or Oberon which are routinely criticised as “too verbose”? Or even Cobol :-) I closely follow the various extensions done to Java over the years, and the changes that are most welcomed by the developer community are things that mean less typing. Surprising, at least to me. |
Steffen Huber (91) 1949 posts |
Unfortunately all docs I know of are in German, but something worth having a look at (not as a useful language, but as a different approach to the more usual languages) is Aalgola by Michael Wiedeking. We have so many useful characters in Unicode – let’s use ’em all! And provide our own font for it! |
nemo (145) 2529 posts |
PostScript. Strings are delimited by (parentheses) instead of “quotes” (Hello Rick!) print Arrays are delimited by [brackets] without commas, and code blocks by {braces}. [1 2 3]{print}forall Associative arrays are delimited by <<this convention>> with keys and values just listed. <<1(One)2(Two)>> 2 get print All white space is equivalent and optional. No punctuation whatsoever. .though backwards think to have do You
JavaScript too. |
GavinWraith (26) 1563 posts |
What is to be said for the idea of to-be-closed variables? Old style
gets replaced by new style
The file with handle I do not know if any other languages have anything similar. It seems to me quite an interesting syntactic development. |
Rick Murray (539) 13806 posts |
On the face of it, it sounds like a useful idea. Cue many programs using global file variables (so the runtime can do the tidying up) in 5, 4, 3….
Ah, yes. It was really hard to make any sense of the printer driver’s output when working normally. When it was failing epically to cope with UTF-8, wow, if you ever want to experience a computer having a nervous breakdown…..
That rather rules out RISC OS as a potential target platform, then. :-)
There. That wasn’t so hard was it? I want a compiler that understands that. |
GavinWraith (26) 1563 posts |
Would that be APL, perchance? |
Steffen Huber (91) 1949 posts |
try-with-resources in Java? Available since Java 7. |
Martin Avison (27) 1491 posts |
APL was certainly weird. Totally unintelligible, unless you knew the meaning of umpteen obscure extra characters on the special keyboard. The ultimate non-self-documenting language. |
Steve Fryatt (216) 2103 posts |
How about
in C#? Or, I think
in VisualBASIC? Not sure about the |
Jeffrey Lee (213) 6048 posts |
Many languages offer similar features – it’s hardly a new concept. The most obvious example I can think of is destructors in C++, available since the early 80’s. |
Chris Mahoney (1684) 2165 posts |
In C# 8 you don’t need the {} any more. You can do this: using StreamReader s = new StreamReader("Foo.txt"); string line; while ((line = s.ReadLine()) != null) Console.WriteLine(line); Of course, that particular example is a bit contrived when you can just do: using StreamReader s = new StreamReader("Foo.txt"); Console.Write(s.ReadToEnd()); :)
My gut says you want “Is Not Nothing” rather than “<> NULL”, but it’s been years since I’ve done any serious VB development. |
Steve Drain (222) 1620 posts |
OK, I’ll bite. ;-) PROCusing("Foo.txt","Console_WriteLine") END DEFPROCusing(file$,do$) LOCAL file% file%=OPENINfile$ IF file% THEN WHILE NOT EOF#file% IFEVAL("FN"+do$+"(file%)") ENDWHILE CLOSE#file% ENDIF ENDPROC In devious ways in just BASIC, I could make this: PROCusing,Foo.text,Console_WriteLine |
Tony Noble (1579) 62 posts |
An alternative or two: $ awk '{print}' foo.txt (I’ll fight anyone who tells me awk can’t be used as a programming language) Or COBOL? identification division. program-id. my-file-reader. environment division. input-output section. file-control. select foo-txt-file assign to "foo.txt" organization is line sequential file status is file-status. data division. file section. fd foo-txt-file. 01 foo-txt-record pic x(80). working-storage section. 01 file-status pic 99 value 0. 88 end-of-file values 1 thru 99. procedure-division. main section. perform until end-of-file read foo-txt-file display foo-txt-record upon crt end-perform stop run . (Edit: my textile knowledge is faulty. This may not appear as it should) |
nemo (145) 2529 posts |
Gavin said
At the risk of repeating myself, PostScript. All PS objects, including files, are subject to garbage collection. When they are no longer being used, they are closed. Mind you, they also get closed when you read the last byte, which isn’t always convenient. Rick recalled
Well yes, and compiler output is certainly not hand-written assembler either.
I’d disagree. ;-) |
Rick Murray (539) 13806 posts |
True, but when you’ve seen it often enough you can get a sense of the underlying code. As was (in)famously(!) demonstrated by Gerph many years back. [lack of] [Unicode] rather rules out RISC OS as a potential target platform You would, but then your RISC OS doesn’t exactly resemble anybody else’s RISC OS, does it? ;-)
I find the COBAL program almost readable, but I wonder… What are the numbers for? What’s the 01 and the 88? Could it be 86? 77?
Ooh, evilly delicious! |
Tony Noble (1579) 62 posts |
re. COBOL – the leading numbers are a ‘level’ – each level encompasses all the levels below it, so you can refer to all or part of a data structure as required. Convention dictates that levels are odd-numbered. Hence:
It’s done that way because the data structures are designed primarily to be overlays on data records from tape/disk. For fun, you can even have redefinitions of the same data structure with different field layouts. That can get…interesting. The level ‘88’ item is a special case – it’s a condition based on the value of the field above it. So in the example I have, ‘end-of-file’ returns logical true when the ‘file-status’ field has any value between 01 and 99. You can also use them in reverse, to set the value of a field (though not in this instance). COBOL is incredibly verbose, but sometimes overly so. It’s fast, but anything slightly oddball is the equivalent of trying to build a lego technic model when you only have Duplo bricks… |
Rick Murray (539) 13806 posts |
Tape and disc? Looking at the way you structure your code, I’m guessing the indentation is not only important but might also curiously match specific columns in punched cards? |
Pages: 1 2