Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: autoload



On Sep 21, 10:03am, Ray Andrews wrote:
} Subject: Re: autoload
}
} On 09/20/2015 09:18 PM, Bart Schaefer wrote:
} > Because the language is
} > interpreted, the shell itself can't decompose a file into individual
} > function entry points the way e.g. a linker can for a shared object.
} 
} Really? That's hard to fathom. I source a file and it finds whatever
} functions may be in there, but they can't be packed into a .zwc file
} without worrying about it's name?

Did you miss the email where I explained how to do that?

} I'd have thought it would be as transparent as:
} 
} zcompile --do_it  /not-the-same-directory-dummy\!/Source.zwc 
} /aWorking/Zsh/Source/*

Really think about "because the language is interpreted."

Suppose I have

    typeset some_critical_var_used_by_foo_and_bar=really_important_value

    foo() { ... }
    bar() { ... }

Now I want to compile this.  Sure, the shell could dump out foo and bar,
but where does it put that typeset?  Does it evaluate the assignment at
compile time?  (A C compiler would, but that's typically the wrong
semantics for a shell.)

What if really_important_value absolutely must only be interpreted once,
not each time foo and bar are individually loaded?

What if the names "foo" and "bar" are actually stored in other variables?

    function $foo { ... }

What if there's an "if" structure?

    if some_runtime_test
    then
	foo() { ... }
	bar() { ... }
    else
        bar() { ... }
	foo() { ... }
    fi

What if there's a runtime test with that crucial typeset INSIDE the test?

I can make up an infinite number of increasingly convoluted cases to
break any "simple, elegant" automation.  So unless you happen to have
"zmodload zsh/artificial-intellgence" lying around ready for use, I'm
done with this discussion.



Messages sorted by: Reverse Date, Date, Thread, Author