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

Re: endianness of wordcode



Bart Schaefer wrote:

> ...
> 
> } I think the zcompile documentation, and maybe other places where wordcode
> } is mentioned, could be friendlier [...]
> 
> Yes.

Thanks, Bart.

> We'd also discussed changing -r/-m to -R/-M and changing -M to -m, but this
> patch doesn't do that yet.

I haven't done that yet either, because I fear I have to do some more
with this yet.

> Sven, please check the accuracy of my edits to func.yo. 

They are correct. At least that's how it should work and seems to work 
for me.

Now...

> In particular
> I'm not sure how to explain what happens if you do
> 
> 	zcompile -c foo foo bar frob ding
> 	fpath=($PWD)
> 	autoload foo
> 	foo

I don't understand what you mean here. If foo is already defined, the
autoload won't change that and you just get that executed. If foo is
unfunction'ed before the autoload, it loads foo.zwc and executes foo
just as expected. At least for me. What am I missing?

> And I'm even more confused by
> 
> 	zcompile -c foo -k foo bar frob ding
> 	fpath=($PWD)
> 	autoload foo
> 	foo
> 
> which first executes "foo" successfully and then prints
> 
> 	foo:3: foo: function not defined by file
> 
> leaving "foo" as an undefined (but marked autoloaded) function.

Here at least `foo' was already defined, right. This is a problem I
hadn't thought about. If we save it to be loaded ksh-style, the init
code originally surrounding the function definition (if there was any) 
is, of course, already deleted. So, the best attempt we could do is to 
put the body of the function in a `foo() { body }' and save that (I
mean, zcompile would do that, the definition of foo in the current
shell wouldn't be changed).

But this is a bit ugly, too. Maybe the user just wasn't aware of this
effect and would have preferred a warning. So maybe we should just do
that. Note also, that for ksh-style autoloaded function that aren't
loaded yet, the whole contents of the definition file is put into the
wordcode file (i.e. one gets different results depending on whether
the function is already loaded or not).

Or maybe we should first try to find the original file defining the
function, if we find one, write that into the wordcode file (but if
foo had been changed in the meanwhile, the changes would be lost, hm), 
if not, do the `foo() { body }' trick.

Hrm. Dunno. I seem to prefer the solution that just prints an error
message and doesn't even try to create the wordcode file in such a
case.

Help, please.

Bye
 Sven


--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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