3 ms·
The language has panics. But you aren't supposed to use them. So...
by pekk 13y ago
The language has panics. But you aren't supposed to use them. So...
- mseepgood 13y agoOf course you are supposed to use them when appropriate; they have their uses just as goto can have its valid uses. The implementation of the standard library contains some examples. But they should be used judiciously and not for mere error handling and not across package boundaries.
- elithrar 13y ago> The language has panics. But you aren't supposed to use them. So... Not true. Panic/defer/recover is there to be used. But panic/recover should typically be internal to a package and/or used in a situation where the program itself suffers an error; not because of faulty user input/validation/etc. Edit: What mseepgood said!
- dragonwriter 13y ago> The language has panics. But you aren't supposed to use them. Conventionally, you generally shouldn't use them in a way that crosses the public interface of the module in which they are used.