RISC OS Open
A fast and easily customised operating system for ARM devices
ROOL
Home | News | Downloads | Bugs | Bounties | Forum | Documents | Photos | Contact us
Account
Forums → Announcements →

RiscLua 8

Subscribe to RiscLua 8 29 posts, 12 voices

Posts per page:

Pages: 1 2

 
Jun 3, 2019 12:57pm
Avatar GavinWraith (26) 1142 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.
Lua 5.4.0 has some new experimental features, notably local variables with the attributes const or toclose. Their syntax may have changed by the time the beta version emerges. The Example and Utilities directories must reside in the same directory as !rlua8 to function. The libraries have been updated in this version, and may be augmented later.

 
Jun 3, 2019 8:48pm
Avatar Matthew Phillips (473) 400 posts

Thanks Gavin!

 
Jun 7, 2019 12:46pm
Avatar GavinWraith (26) 1142 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.

 
Jun 13, 2019 9:40am
Avatar Stephan Kleinert (2271) 60 posts

Great work! Many thanks, Gavin!

 
Jun 13, 2019 12:45pm
Avatar GavinWraith (26) 1142 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.

 
Oct 3, 2019 1:24pm
Avatar GavinWraith (26) 1142 posts

Lua 5.40 (beta) is now out. The only syntactic change from alpha (which RiscLua 8 is based on) is that

local <toclose> x = …

is now

local <close> x = …

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:

local <toclose> x = setmetatable ( { }, {
__tostring = \ (…) => “hi” end;
__close = \ (a) print (a) end;
})

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.

 
Oct 3, 2019 1:42pm
Avatar Rick Murray (539) 10304 posts

This example for RiscLua 8 might amuse

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…

 
Oct 3, 2019 2:35pm
Avatar GavinWraith (26) 1142 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:

Define x to be an empty table, with two special properties: it should be printed out as “hi”, and when it goes out of scope it should be printed out.

The braces after the word local denote an attribute and are new to version Lua 5.40. The statement x = { } is no worse, by itself, than let x be an empty table. Parentheses to show arguments to functions and semicolons to separate the key-bindings of a table, and double-quotes to enclose the characters in a string, are all pretty standard. The three dots denote an unspecified list of arguments, and braces enclose a table, according to Lua. The backslash and the => for function and return, respectively, are RiscLua trying to be more terse. The double underscores is a Lua convention for keys denoting events, things that happen while the interpreter is digesting the text of the program – in this case when something is fed to the print function and when it goes out of scope.

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.

 
Oct 3, 2019 3:11pm
Avatar Steffen Huber (91) 1597 posts

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?

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.

 
Oct 3, 2019 3:19pm
Avatar Steffen Huber (91) 1597 posts

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?

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!

 
Oct 3, 2019 3:40pm
Avatar nemo (145) 2136 posts

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?

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

We have so many useful characters in Unicode – let’s use ’em all!

JavaScript too.

 
Oct 3, 2019 7:19pm
Avatar GavinWraith (26) 1142 posts

What is to be said for the idea of to-be-closed variables? Old style

local f = io.open (filename)
do_summatwith (f)
f:close ( )

gets replaced by new style

local <toclose>  f = io.open (filename)
do_summatwith (f)

The file with handle  f gets closed automatically in the new style when it goes out of scope. In the old style the programmer has to choose where to put the explicit f:close ( ) statement. It does not matter where so long as it is placed after anything that uses the filehandle and before it goes out of scope. So this is removing unnecessary choice from the programmer, which I see as helpful, and concealing the necessary work within the interpreter. The mechanism is sufficiently general to work with any kind of user-defined object which needs to clean up after itself.

I do not know if any other languages have anything similar. It seems to me quite an interesting syntactic development.

 
Oct 3, 2019 7:55pm
Avatar Rick Murray (539) 10304 posts

It seems to me quite an interesting syntactic development.

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….

.though backwards think to have do You

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…..

We have so many useful characters in Unicode – let’s use ’em all!

That rather rules out RISC OS as a potential target platform, then. :-)
Still, I’m not sure that learning Hymnnos in order to write a program is quite what I meant, though I have seen examples of a programming language that used a lot of weird characters, maybe that was Aalgola?

Define x to be an empty table, with two special properties: it should be printed out as “hi”, and when it goes out of scope it should be printed out.

There. That wasn’t so hard was it? I want a compiler that understands that.

 
Oct 3, 2019 9:31pm
Avatar GavinWraith (26) 1142 posts

.. a programming language that used a lot of weird characters

Would that be APL, perchance?

 
Oct 3, 2019 9:36pm
Avatar Steffen Huber (91) 1597 posts

I do not know if any other languages have anything similar. It seems to me quite an interesting syntactic development.

try-with-resources in Java? Available since Java 7.

 
Oct 3, 2019 9:37pm
Avatar Martin Avison (27) 1033 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.

 
Oct 3, 2019 10:19pm
Avatar Steve Fryatt (216) 1411 posts

I do not know if any other languages have anything similar.

How about

using (StreamReader s = new StreamReader("Foo.txt")) {
  string line;

  while ((line = s.ReadLine()) != null)
    Console.WriteLine(line);
}

in C#? Or, I think

Using s As New StreamReader("Foo.txt")
  Dim line As String
  
  While ((line = s.ReadLine()) <> NULL)
    Call Console.WriteLine(line)
  End While
End Using

in VisualBASIC? Not sure about the While ((line = s.ReadLine()) <> NULL) syntax in that latter example – I’m not a regular VB programmer, thankfully… The Using bit is correct, though. :-)

 
Oct 3, 2019 10:24pm
Avatar Jeffrey Lee (213) 5821 posts

I do not know if any other languages have anything similar. It seems to me quite an interesting syntactic development.

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.

 
Oct 3, 2019 11:44pm
Avatar Chris Mahoney (1684) 1667 posts

in C#?

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());

:)

Not sure about the While ((line = s.ReadLine()) <> NULL) syntax in that latter example

My gut says you want “Is Not Nothing” rather than “<> NULL”, but it’s been years since I’ve done any serious VB development.

 
Oct 4, 2019 9:59am
Avatar Steve Drain (222) 1299 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
 
Oct 4, 2019 11:44am
Avatar Tony Noble (1579) 63 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)

 
Oct 4, 2019 2:38pm
Avatar nemo (145) 2136 posts

Gavin said

I do not know if any other languages have anything similar. It seems to me quite an interesting syntactic development.

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

It was really hard to make any sense of the printer driver’s output when working normally.

Well yes, and compiler output is certainly not hand-written assembler either.

[Unicode] rather rules out RISC OS as a potential target platform

I’d disagree. ;-)

 
Oct 4, 2019 6:31pm
Avatar Rick Murray (539) 10304 posts

Well yes, and compiler output is certainly not hand-written assembler either.

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

I’d disagree. ;-)

You would, but then your RISC OS doesn’t exactly resemble anybody else’s RISC OS, does it? ;-)

01 file-status pic 99 value 0.
88 end-of-file values 1 thru 99.

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?

OK, I’ll bite. ;-)

Ooh, evilly delicious!

 
Oct 4, 2019 6:58pm
Avatar Tony Noble (1579) 63 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:


01 my-whole-data-structure.
03 my-smaller-structure.
05 field-one pic xx.
05 field-two pic s9(5).
03 my-field-here pic x(80).
03 my-other-smaller-structure.
05 field-three pic x.
05 field-four pic 99 value 0.

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…

 
Oct 4, 2019 7:33pm
Avatar Rick Murray (539) 10304 posts

to be overlays on data records from tape/disk.

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?

Next page

Pages: 1 2

Reply

To post replies, please first log in.

Forums → Announcements →

Search forums

Social

Follow us on and

ROOL Store

Buy RISC OS Open merchandise here, including SD cards for Raspberry Pi and more.

Donate! Why?

Help ROOL make things happen – please consider donating!

RISC OS IPR

RISC OS is an Open Source operating system owned by RISC OS Developments Ltd and licensed primarily under the Apache 2.0 license.

Description

Announce and discuss new hardware and software releases.

Voices

  • GavinWraith (26)
  • Matthew Phillips (473)
  • Stephan Kleinert (2271)
  • Rick Murray (539)
  • Steffen Huber (91)
  • nemo (145)
  • Martin Avison (27)
  • Steve Fryatt (216)
  • Jeffrey Lee (213)
  • Chris Mahoney (1684)
  • Steve Drain (222)
  • Tony Noble (1579)

Options

  • Forums
  • Login
Site design © RISC OS Open Limited 2018 except where indicated
The RISC OS Open Beast theme is based on Beast's default layout

Valid XHTML 1.0  |  Valid CSS

Powered by Beast © 2006 Josh Goebel and Rick Olson
This site runs on Rails

Hosted by Arachsys