On 4/23/06, Philip Ganchev <[EMAIL PROTECTED]> wrote: > On 4/22/06, Axel Liljencrantz <[EMAIL PROTECTED]> wrote: > > On 4/22/06, Philip Ganchev <[EMAIL PROTECTED]> wrote: > > > > > > > > Would it be terrible if the error message also printed the value of > > > variable PWD? > > > > They do! The body of the suggested fundtion is the value of PWD. > > Oh, I didn't notice! > > On second thought, the user probably just wants to access the value of > the variable "PWD", not define a function. So the error message like > this would be more helpful: > > fish> $PWD > fish: Variable 'PWD' has value '/home/mojo/'. Variables may not be > used as commands! Instead, you can type 'echo $PWD', or define a > function like > 'function PWD; echo /home/mojo/; end'. To read about the 'function' > command, type 'help function'.
The trouble with trying to guess what the user is trying to do is that you are bound to get it wrong sometimes. I'm sure that some users who simply write out a variable name expect the value of the variable to be executed as in other shells, while other users, perhaps those coming from the C world, expect it to be printed. There are probably other interpretations as well. The syntax error hints in fish are mostly designed to guide someone who knows how to use a Posix shell, since I'm guessing that a lot of people who try out fish are in fact Posix shell users. I am also hesitant to add two different suggestions as in your example - there has to be a line somewhere on the verbosity of error messages. > > > > > [...] > > > > > > fish> function say!hello; echo hello; end > > > > > > fish: Invalid character '!' in function name. Only alphabetic and > > > > > > numeric characters and underscore are valid. > > > > > > > > > > > > > > Since posix does not prevent filenames from containing a '!', I think > > > > this error is misleading. There could have been a command called > > > > 'say!hello' and it would run just fine. > > > > > > But Fish prevents functions from containing a '!', which is just what > > > the messages says. You can't define a function called 'say!hello'. > > > > True, but doesn't the message imply that because functions dialow it, > > that this is an illegal command name, when the truth is that a regular > > command may contain a '!'. > > I don't think it implies it. It says it is an illegal function name, > not an illegal command name. Perhaps it would be clearer, we could > say "You cannot define a function with that name. ...". What one reads into something unsaid is rather arbitrary. The way I read the original error message, there was an _unspoken_ implication that commands in general may not contain a '!' in the second sentence. It is not obvious to me when reading the message that the scope of the first sentence applies to the second one as well. That can actually be fixed by specifying the exact scope of the second sentence: fish> function say!hello; echo hello; end fish: Invalid character '!'. Only alphabetic and numeric characters and underscore are valid in function names. I'm guessing the main point you wanted was to tell the user exactly what was wrong with the function name, which is an excellent idea. Perhaps it could be shortened to 'Only alphanumeric characters and underscore are valid in function names'? > But it is true that we wanted to make builtins, functions and > executable files used in the same way. And this naming convention > breaks exposes the difference. Yes, that is unfortunatly true. The alternative would be to allow function names to contain 'weird' characters, which would in my view make it logical to also allow variable names to contain 'weird' characters. Which would make parsing harder (for both humans and computers) and probably lead to unintuitive edge cases. I'm pretty sure that a rather conservative approach with regards to legal characters in variable names is the right thing. It's not obvious to me if it is more important to have the same naming restrictions on both variable names and function names, or to have the same naming restrictions on command names and functions. I like the consistency and neatness of having the same name restrictions on functions and variables. From a language point of view it makes a huge amount of sense. But from a users point of view, functions are more obviously related to commands. I've considered adding scope to function names, so that you could create functions that can only be called from within other functions. This type of syntax allows you to implement object orientation with data hiding and very powerful name space mechanisms, but would require that some cheracters (e.g. ':' and '.') be reserved as scoping operators, and be made illegal in function names. For example Lua uses this method to implement high level concepts like OO. On the other hand, why on earth should a _scripting language_ have namespaces, data hiding and OO? If you want to write a complex object oriented program, use another programming language. > > > The real problem is simply > > that a command with the specified name doesn't exist. The fact thatthe > > given command name is also not a legal function name is not the main > > problem. > > It doesn't matter that it does not exist. The user is trying to > _define_ a new function with a weird name. That's the problem. I was a bit confused when writing that, I though I was replying to something else. My bad. -- Axel ------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid0709&bid&3057&dat1642 _______________________________________________ Fish-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/fish-users
