Standard Lua Library

classic Classic list List threaded Threaded
25 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Re: Standard Lua Library

Rici Lake-2

On 12-Jan-07, at 10:23 AM, James Hearn wrote:

Can you give any examples of other programming languages that does
something similar? inject functions into other namespaces?

In Ruby all classes and modules are "open" meaning that other classes
are free to inject, patch, or otherwise modify their class
definitions. As a particular example Ruby on Rails adds functionality
to core classes like strings and numbers (!) It's definitely a
different approach than the standard in most other languages, but the
Ruby camp considers it a strength rather than a drawback.

This is also considered a strength of Smalltalk / Squeak and Objective-C, as I understand it.


Reply | Threaded
Open this post in threaded view
|

RE: Standard Lua Library

Jay Carlson
In reply to this post by D Burgess-4
Squeak has spent years trying to modularize after decades of designing this way, though.  Stuff like GUI toolkit methods on Object are imposing to the new user.

This is not inevitable but it is a cautionary tale.

-- 
Jay
Sent from a Treo, excuse infelicities

-----Original Message-----
From: "Rici Lake" <[hidden email]>
To: "Lua list" <[hidden email]>
Sent: 1/12/07 7:32 AM
Subject: Re: Standard Lua Library


On 12-Jan-07, at 10:23 AM, James Hearn wrote:

>> Can you give any examples of other programming languages that does
>> something similar? inject functions into other namespaces?
>
> In Ruby all classes and modules are "open" meaning that other classes
> are free to inject, patch, or otherwise modify their class
> definitions. As a particular example Ruby on Rails adds functionality
> to core classes like strings and numbers (!) It's definitely a
> different approach than the standard in most other languages, but the
> Ruby camp considers it a strength rather than a drawback.

This is also considered a strength of Smalltalk / Squeak and 
Objective-C, as I understand it.




Reply | Threaded
Open this post in threaded view
|

Re: Standard Lua Library

David Given
In reply to this post by Rici Lake-2
Rici Lake wrote:
[...]
> This is also considered a strength of Smalltalk / Squeak and 
> Objective-C, as I understand it.

Yes, this dates back from Smalltalk-80 and before.

Reasoning:

- make a subclass on Number called Distance. You can now make a Distance
  object representing five metres with 'Distance new: 5'.
- add a method to Number, 'metres', that calls 'Distance new: n'.
- add a method to Number, 'feet', that calls 'Distance new: (n * 0.304.8)'.

You may now say '5 metres' or '18 feet' to construct Distance objects. Natural
and intuitive. (There's a namespace mechanism in place to prevent namespace
pollution.)

I find it rather amusing that practically every shiny new language feature
that are in fashion today were, in fact, done 27 years ago by Smalltalk-80.
People don't learn from history...

-- 
âââ ïïïïïïïïïïïïïï âââ http://www.cowlark.com âââââââââââââââââââââ
â "Is Eris true?" "Everthing is true." "Even false things?" "Even false
â things are true." "How can that be?" "I don't know, man. I didn't do it!"
â --- _Prinicipa Discordia_

Attachment: signature.asc
Description: OpenPGP digital signature

Reply | Threaded
Open this post in threaded view
|

Re: Standard Lua Library

Chris-41
On 1/12/07, David Given <[hidden email]> wrote:
I find it rather amusing that practically every shiny new language feature
that are in fashion today were, in fact, done 27 years ago by Smalltalk-80.
People don't learn from history...

Tell that to the Lisp people who were doing it way before Smalltalk-80.  ;)

Just like most things in life it's extremely rare to discover
brand-new never-been-seen-before ideas.  Artwork, music, software,
etc. for the most part it's all rehashing old ideas.  Plus you can't
expect everyone to know everything about everything, that's
impossible.

Success depends on the specific arrangement of ideas (eg. _how_ you do
something) more than having a completely original idea.  The devil is
in the details as they say.

CR

Reply | Threaded
Open this post in threaded view
|

Re: Standard Lua Library

Natanael Copa
In reply to this post by Rici Lake-2
On Fri, 2007-01-12 at 10:32 -0500, Rici Lake wrote:
> On 12-Jan-07, at 10:23 AM, James Hearn wrote:
> 
> >> Can you give any examples of other programming languages that does
> >> something similar? inject functions into other namespaces?
> >
> > In Ruby all classes and modules are "open" meaning that other classes
> > are free to inject, patch, or otherwise modify their class
> > definitions. As a particular example Ruby on Rails adds functionality
> > to core classes like strings and numbers (!) It's definitely a
> > different approach than the standard in most other languages, but the
> > Ruby camp considers it a strength rather than a drawback.
> 
> This is also considered a strength of Smalltalk / Squeak and 
> Objective-C, as I understand it.

Even if I agree it can good to be able to do it, I fail to see why is it
"best practices" to actually do it.

I fully agree with the following comment on
http://lua-users.org/wiki/ExtensionProposal

"Mark, thanks for this implementation. I'll add to the chorus here of
keeping functions only under the ex module and by default not
"polluting" (to use the term from Perl) the os and io modules. If the
user chooses to pollute the standard io and os modules, they may do so
by explicitly calling an ex.install() or similar function as suggested
above. That gives users a choice. I'd recommend this practice at least
until the Lua standardization people give a stamp of approval."




12