lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


  I'm replying to the entire thread, but starting here.  My initial
thoughts, upon reading all your posts and GitHub site, is that what you are
trying to do has been attempted before, more notably:

	* Hypercard
	* Apple Script

  You might want to look at those systems to see how they worked (and didn't
work) for more insights into the problem you are trying to solve.  You might
also want to look into the programming language Forth, as that has way more
freedom than any other language as to what an identifier is, along with a
lack of distinction between a function call and a value reference.

  Now, with that out of the way:

It was thus said that the Great Claudio Grondi once stated:
> 
> Lua would require some minor changes only, which if I am not mistaken
> won't break any past code and should be relatively easy to implement, in
> order to support natural language texts as valid script code.
> 
> May someone help me to provide proof of the concept explaining where and
> how to modify Lua C-code in order to:
> 
> 1.    allow ASCII values 0x02 (Start of Text) and 0x03 (End of Text) to
> be used in script code and interpreted respectively as `[[` and `]]`

  The major problem here is allowing Lua to use STX and ETX to mark long
strings, but getting existing systems to make it easy to type STX and ETX.
I would be hard pressed to get my preferred text editor to include those
characters into a file, expecially ETX (which is Ctrl-C, which a lot, *a
lot* of programs, interpret as an interrupt character.

  Yes, a new editor or system can be created that allows the use of
non-printable characters, but now you have to convince people to use your
editor or system.  And the industry is littered with such projects, most
never finished.

> On 10/1/23 17:51, Lars Müller wrote:
> > > 
> > > 2.    allow function calls by specifying the function name only (without
> > > using braces and without the need of passing a parameter)
> > 
> >2. Would break existing code and introduce many syntactic ambiguities.
> >Consider the simple p = print. Is this an assignment p = print() or an
> >assignment p = print?
> 
> In my general concept of an oOo system using a text editor for invoking
> executable actions instead of a shell usage of an assignment isn't part
> of the concept. And because p=print() and p=print is already handled in
> Lua, there is no need to worry about ambiguities. It's ok as it is ...

  As Lars stated, this would break existing code:

> function f() return 42 end
> x = f ; print(x)
function: 0x8cc2020
> x = f() ; print(x)
42

  As you stated above:

> Lua would require some minor changes only, which if I am not mistaken
> won't break any past code and should be relatively easy to implement, in
> order to support natural language texts as valid script code.

  This breaks existing Lua code.

  Also, what does "oOo" mean?  "Out-of-order"?  "Object-Oriented-something?"
It's not clear.

> > > 3.    extend [_a-zA-z0-9] characters allowed in symbol names with ASCII
> > > value 0x1F (Unit Separator) and `-` which will be treated like [0-9] not
> > > allowed as first symbol name characters
> >
> >3. Again a nonprintable control character. Adding hyphen would introduce
> >ambiguities, breaking existing code again: Is a-b the name a-b or the
> >subtraction a - b?
> 
> `a-b` is clearly a name. 

  In your opinion.  In mine, "a-b" is clearly two variables being
subtracted.  And in most languages, this is the case.  There is only one
language I know of (there could be others) where this would be a valid
label, and that's Forth.  

> To achieve subtraction you would need to
> separate the operator from the variable names `a - b`. Like a*b could be
> also made a name .. In the general concept of oOo system a*b will be a
> name of a function which performs multiplication of the value stored in
> a variable with name `a` with the value stored in the variable with name
> `b`. 

  Why not logically AND the value of a with the value of b?  Or match the
pattern stored in a AND match the pattern stored in b (as in LPEG)?

> The idea is to refrain from usage of internal variable names in
> usual sense, replacing them with a mechanism of getting the values from
> appropriate named files. And as files allow any characters in them ...
> there is actually no reason to restrict variable and function names to
> [_a-zA-z0-9], but .. to achieve simplicity and avoid the need to cope
> with utf-8 encoding and Unicode I tend to prefer the idea to stick with
> one-byte ASCII and an own kind of encoding with appropriate true type
> font for use in a text editor to write scripts.

  Good luck in getting it adapted.  People who don't speak English will
probably want to use their own language.

> Let me give an example of the main idea I want to create as a proof of
> concept using Lua.
> Let's prepare first some functions for later use:
> 
> > function let_x_be(val) x = tonumber(val) end
> > function let_y_be(val) y = tonumber(val) end
> > function let_z_be_sum_of_x_and_y ()  z = x + y end
> 
> With this functions defined, Lua already allows to write following code:
> 
> > let_x_be '0xff' _=',' let_y_be '15' _='and' let_z_be_sum_of_x_and_y''
> 
> The result of the code above is:
> > x
> 255
> > y
> 15
> > z
> 270

  And what's wrong with?

	let_x_be = 255
	let_y_be = 15
	let_x_be_sum_of_x_and_y = let_x_be + let_y_be

That's a hell of a lot easier to type that your example.  And if you need to
explain why, you can always use comments.  Or Literate Programming, which
encourages one to extensively document the program without regard to how the
code needs to be structured.

> The actual problem I see is to explain to someone who is deeply into the
> existing programming mechanisms and paradigms what the final goal and
> concept of oOo is, because it goes beyond usual understanding of what a
> programming language is for.
> 
> The core idea is to use the keyboard to write a text in a text editor and
> invoke all the systems functionality from there using a custom language
> created out of the available functionalities (mixing usage of executable
> files written in various programming languages).

  Sounds like you are recreated shell scripts.  Or Apple Script.  Also, how
would one use your system to write a new text editor that supported these
ideas?  Just curious.

> Once you have got the main idea of what I am actually after, then you will
> much better understand how to help to achieve it providing the appropriate
> language means making it possible.  In my eyes Lua is the best language
> available for this purpose if slightly modified to support more freedom of
> choice while writing code.

  You need to clarify your ideas, and personally, I'm not sure if Lua is the
best choice for this---yes, the code can be modified but at that point, it's
no longer Lua.  

  -spc