On 06/10, David Holland wrote: > On Wed, Jun 10, 2020 at 01:25:03AM -0400, Thor Lancelot Simon wrote: > > Could you translate your prototype into a > > different language, one that's less basically hostile to our build system > > and its goals and benefits? > > Like which one?
How about mruby? https://mruby.org/ It's small and lightweight. IMO, the Ruby language is quite nice. I believe mruby can be cross-compiled since in https://github.com/mruby/mruby/blob/master/doc/guides/compile.md it says: mruby uses Rake to compile and cross-compile all libraries and binaries. It looks like it supports GCC and Clang. Unfortunately, one prerequisite it lists is a Ruby 2.0 or later implementation. That obviously makes compiling harder. :-( Given that it seems to be targeting being linked and embedded in an application, I guess I can see why they don't mind this dependency. For the idea of possibly including it in base, though, it's unfortunate. Anyway, I'm talking about mruby just because it's a small and lightweight implementation of the Ruby language that might have a better chance of getting included in base if that were ever considered desirable. Since you're just looking for a reasonable language, though, I still think Ruby would be an excellent choice, and the de facto standard CRuby (a.k.a. Matz's Ruby Interpreter or Ruby MRI) https://www.ruby-lang.org/ would be a nice implementation. I believe it can be cross-compiled. And it's obviously available in pkgsrc. > You removed the part of the post that explained that there aren't other > reasonable choices. > > Yes, it can be rewritten in C as a subsequent step. *After* quite a > bit of tidying. And no, I'm not doing that now. Among other problems, > compiling it requires bikeshedding where to put it in the tree. Feel > free to sort that out. > > As for lua: it has the same headline issues as awk, namely it doesn't > enforce function arguments and doesn't require that variables are > declared before use. Again, I see no reason to think it'll be any more > maintainable. I don't know anything about Lua, and I might be completely misunderstanding what you're saying, but I think Ruby satisfies both of those as follows (mruby and CRuby output shown): * It enforces function arguments: ---- $ cat func_args.rb def add(x, y) x + y end puts(add(5)) $ mruby func_args.rb trace (most recent call last): func_args.rb:5: 'add': wrong number of arguments (1 for 2) (ArgumentError) $ ruby func_args.rb Traceback (most recent call last): 1: from func_args.rb:5:in `<main>' func_args.rb:1:in `add': wrong number of arguments (given 1, expected 2) (ArgumentError) ---- * It requires variables to be assigned before use: ---- $ cat var_use.rb puts(foo) $ mruby var_use.rb trace (most recent call last): var_use.rb:1: undefined method 'foo' (NoMethodError) $ ruby var_use.rb Traceback (most recent call last): var_use.rb:1:in `<main>': undefined local variable or method `foo' for main:Object (NameError) ---- Lewis