bug-bash
[Top][All Lists]
Advanced

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

Re: Patch for autoload.v3 to allow export of function


From: Matthew Persico
Subject: Re: Patch for autoload.v3 to allow export of function
Date: Thu, 17 Aug 2017 10:40:01 -0400

It has finally occurred to me after 24 hours that attachments are pretty
useless in this forum. I will repost this evening with the contents in the
mail body. And, since this is not longer a patch but really a rerwite, I'll
use a fresh thread.

On Wed, Aug 16, 2017 at 1:56 AM, Matthew Persico <matthew.persico@gmail.com>
wrote:

> Please see the attached 'autoload.v4' and 'autoload.v4.t'.
>
> On Mon, Aug 14, 2017 at 10:30 AM, Chet Ramey <chet.ramey@case.edu> wrote:
>
>> On 8/11/17 6:55 PM, Matthew Persico wrote:
>>
>> > What I propose to do between steps 2 and 3 is
>> >
>> > 2.1 - After sourcing the function in, type the function to get its text
>> > 2.2 - type appears to pretty print function code. No matter how sloppy
>> or
>> > compact your function is on disk, type presents it to you in a
>> particular
>> > format. To wit, for a function 'foo'
>> >
>> > foo is a function
>> > foo ()
>> > {
>> >     first line of code
>> >     ....
>> > }
>> >
>> > That's regular. Therefore it can be parsed.
>> >
>> > 2.3 - With the output of the type command, I strip out line 1 and after
>> > line 3, I add the text
>> >
>> > local AUTOLOADED='foo'
>> >
>> > 2.4 - evaling the modified code updates the function to include that
>> line
>> >
>> > 2.5 - Determining if a function is autoloaded is as simple as executing
>> > (something like)
>> >
>> > $ type foo | grep 'local AUTOLOADED='foo'.
>> >
>> > which is REALLY REALLY fast, even under Cygwin on Windows 10. Yeah,
>> that's
>> > one of the environments I'm using for testing.
>> >
>> > No more unexportable arrays and hashes. Self documenting. And
>> 'AUTOLOADED'
>> > can be changed to something less likely to clash with existing code.
>> And we
>> > document that any function you are going to autoload must avoid using
>> the
>> > variable AUTOLOADED, or whatever it is eventually.
>> >
>> > So, before I post code here, what say you all? Is the idea of doing this
>> > code injection so hideous that it would never be accepted, or is it
>> worth
>> > submitting the code for perusal?
>>
>> Of course it's worth submitting the code for folks to look at. It might be
>> possible to add a couple more checks to insulate it against possible
>> future
>> changes to the `type' output.
>>
>> --
>> ``The lyf so short, the craft so long to lerne.'' - Chaucer
>>                  ``Ars longa, vita brevis'' - Hippocrates
>> Chet Ramey, UTech, CWRU    chet@case.edu
>> http://cnswww.cns.cwru.edu/~chet/
>>
>
>
>
> --
> Matthew O. Persico
>



-- 
Matthew O. Persico


reply via email to

[Prev in Thread] Current Thread [Next in Thread]