lua-users home
lua-l archive

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


Copied to the list becasue I want to share the response

 to help me find a way to resolve the problem

Ale


-------- Mensaje reenviado --------
Asunto: Re: Functions as first-class objects
Fecha: Sat, 1 Sep 2018 20:38:44 -0300
De: Alejandro Reimondo <aleReimondo@smalltalking.net>
A: Egor Skriptunoff <egor.skriptunoff@gmail.com>


Hi Egor,


>What does "send messages to functions" mean?


In object paradigm (Object Technology) the only way to

 interact with an object is sending messages.

We/anObject impact other object sending messages.

To send a message we need a receiver that is the object

that will react to the message sent.


In object ORIENTED languages, e.g. languages that defines

 entities that are not objects, the problem impose limitations

 for changes during the lifetime of the system (the system

is not open in all directions).


In Lua we have tables (that can be used to implement

objects) and values.

The values (string, function, boolean, nil) impose rigid

semantics and do not let the system evolve in that corners.

The case of Strings in Lua, can be patched changing the metatable

 of one string (all strings share the same metatable).

As I know, Functions do not share a standard metatable,

 and we can´t apply the same mechanism to extend semantics

 of functions.


Changing the metatabe of each function is not a solution,

 because functions are allocated anytime and anywhere.


With the information & knowledge I have today on Lua,

 I do not see a way to extend all functions of a system

 modifying one object/metatable.


hope the explanation helps to understand

what I need to resolve.

w/best regards,

Ale







El 31/08/2018 a las 17:48, Egor Skriptunoff escribió:

On Fri, Aug 31, 2018 at 7:29 PM, Alejandro Reimondo wrote:
Is it possible to send messages to functions?
I need to extend functions as first-class objects.
With string values the feature is implemented
extending string's metatables.
I coudn´t found a similar way to do it with
 function values.


What does "send messages to functions" mean?

The "__call" metamethod is not applicable to closures, but others ("__pow", "__div", "__index",...) are still available.