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

Re: try(X) in exec.c ?



On Jan 15, 12:21pm, Daniel X. Pape wrote:
} Subject: try(X) in exec.c ?
}
} I wanted to ask if someone could tell me what the purpose of the return
} value of the macro try(X) in exec. is? (In the zsh-3.1.5-pws-4 source)
} 
} As far as I can tell, the newly allocated string that try(X) returns is
} not assigned to anything at the four places in exec.c that it is used ...
} so that string never gets freed.

It's a macro.  A return statement in a macro doesn't return anything from
the macro, it returns it from the function that calls the macro.  So the
value is returned from findcmd(), and you have to look at the calls to
findcmd() to see whether the string gets freed.

I don't know who named the try() macro; it was a pretty awful choice, and
conventionally any macro that refers to its argument more than once should
be written in all upper case (to remind programmers not to call it with
autoincremented parameters).  Renaming try(X) to MAYBE_RETURN(X) or some
such might be a good idea.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com



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