Hi. I have been using Julia for more than a year, but because Julia is Julia, I still feel like a Newbie, so please be gentle.
I have searched everywhere for a simple test of existence of a variable, like exist() in MATLAB. I saw a post for isdefined(x) but it was old and didn’t work (seems to want 2 arguments, which I didn’t understand and could find any clear documentation on). At the moment I am using
function exist(x); ind=true; try; x=x; catch; ind=false; end; return ind; end
It’s usually more common just to assign nothing to x on top of the function though, and then checking for x === nothing in the body. Otherwise you might run into problems if x is already defined in global scope.
Sorry - yes, macros then. In this case, there is a very handy in-built macro doing (arguably) exactly what most people would be wanting who looked up this part of ‘Help’, yet the macro you mentioned doesn’t appear anywhere in the documentation that I can see. I am sure there must be lots of other in-built macros that are not clearly documented? Or perhaps there is somewhere where they all hide?
If you think it should be mentioned at a specific point in the manual, a PR would certainly be appreciated. I don’t think it’s reasonable to expect that every macro gets mentioned in the main documentation though, since there are quite a lot of them in Base and I don’t think this would be that useful to most people.
I think a mention of this macro in the help would have really saved me (and you!) alot of time and bother here, but I am appreciative of your taking the time.
I also teach lots of students, and while I am sure there is beauty in the abstraction to the 2-argument version of the function, I know that every single one of my (hundreds) of students would be looking for the simple (single-argument) answer, which is the one you gave me. I’m just wondering why it has to be so hard to find? Things like this are a barrier to my using Julia in teaching which I would like to do.
I understand that you might have missed it, because it is just an indirect, not very explicit reference. But you are in the best position to suggest how it might be clearer: Add a link to @isdefined in that FAQ? A more explicit comment on it in the docstring of isdefined…?
As @simeonschaub told, if you are user of Github you may propose a modification to the documentation yourself. (There is an “Edit on Github” link a the top of the documentation pages.)
It just seems to me that the documentation is written as if the audience is those who are already experts in Julia and its ways of doing things. The examples seem to be chosen to exhibit the greatest degree of generality of the functionality of what is being documented, rather the simplest cases.
I am not saying that all the generality should not be demonstrated, but perhaps some very basic examples also included, which does not seem part of the ‘culture’ at the moment.
I tried to do as you suggested, but I couldn’t even figure out how to suggest a change/addition - seems like it is only for experts. [I have contributed to Wikipedia in the past without issue, but I wouldn’t have a clue how to proceed with this. Again, it seems like (as I said) the dominant culture here tends towards ‘by experts for experts’ - I am not complaining as I am grateful that Julia is even there at all, I am just saying that as someone who does not wish to dedicate my whole life to Julia, I feel marginalised]