lua-users home
lua-l archive

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

>> Probably you'd better start with examples of "script in natural language".

>> Natural language is a vague thing and it is difficult to reach a
>> vague goal.  You probably rather aim to parse something which _looks
>> like_ natural language but isn't it.

Well put.  I concur.

> 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

None of that is natural language.  It is, to adapt slightly the phrase
above, something which looks a bit like natural language but is FAR
more restrictive.

> [...] not necessary to give a string literal a name should not brake
> anything and be not that hard to implement [...]

Normally, I would ignore the misspelling.  But in this case, this is
too perfect an example of how unsuited natural language is to

As an English speaker, I can understand the above just fine, even
though it has "break" misspelt as "brake".  Compounding the difficulty
is that, even without allowing for the misspelling, it is perfectly
grammatical.  But the use of the verb "brake" in that context is
unlikely enough to prompt my natural-language linguistic machinery to
look for alternatives; in this case, an anagram error and a homophone
error strike me as significantly more plausible than actual intent to
use "brake" - and that's a human-layer judgement call, even though it
happened subconsciously (at first).

Performing that kind of error correction in software will be extremely
difficult; my estimate is that it is an AI-complete task.

>> Let_x_be 0xff 'and' let_y_be 15 . 'With x and y values set 
> respectively to 255 and 15', let_z_be_sum_of_x_and_y .

This is unnatural language in at least three ways that come to mind
immediately (the use of underscores instead of spaces, in very precise
cases; the unnatural placement of spaces before full stops; and the
surrounding of certain text with ' '); it is bad programming in another
respect (there is a comment which is important to understanding the
code, but it is not code and will not cause any non-human-layer issues
if, say, 0xff is changed to 0x1ff but the comment is not updated.

> This would turn Lua into a programming language making it possible to
> write code in way which reads like natural language sentences

But cannot be written like natural language sentences, which is an
extremely important difference.  Making code _read_ like natural
language is not nearly as important as making it _write_ like natural

It sounds to me as though what you want was already done, better,
decades ago.  It's been at least a decade since I read anything on it,
but here's what my memory hands me, assuming a constant parser which
can handle 0x-prefixed hex:

	MOVE 0xff TO X

/~\ The ASCII				  Mouse
\ / Ribbon Campaign
 X  Against HTML
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B