On Fri, Sep 19, 2014 at 8:53 PM, Keith Medcalf <kmedc...@dessus.com> wrote:
> >Please carefully re-read my comment: 'defined as "char**" or equivalent'. > >"char** argv" is the same as "char* argv[]" in every way except for > >spelling. > > but char** is not equivalent to sqlite_value** and a scalar function > definition has a type of void > (*xFunc)(sqlite3_context*,int,sqlite3_value**) > I understand that. My point was that a person can be forgiven for making the mistake of assuming something to be one way based on limited experience. I'm sure we've all made such mistakes in the past. I *know* I have. The question posed was not "how should I write a query to generate output X Y Z" or "how does VDBE works so that I can skip the SQL stage while writing my database queries". It was "I don't understand why this isn't working" (which I guess is more of a statement than a question, but the question was implicit). I don't think admitting a lack of knowledge is something we should fear. > void functionName(sqlite3_context* a, int b, sqlite3_value**c) > > granted the main function is > > int main(int a, char**b) > > but spelling "c" as "argv" does not change the type to "char**". > I'm sorry for whatever I said that leads you to believe I think changing the name of a parameter / variable changes the type. I thought I was pretty clear that the understandable confusion was in the recycling of the use of argv as a symbol in a different context. There is nothing wrong with it, I wouldn't suggest changing it, just saying that confusion by less experienced programmers is understandable. I could write my own version of standard library functions that do unexpected tasks (maybe strcpy does strcat and strcat does strcpy!) and virtually everyone would understand why that is confusing. I am reusing names with a well defined meaning to do different tasks. In this case argv does essentially the same thing but in a slightly different way. > You too. However, I would point out that there is a big difference > between a symbol name and the type declared for that symbol in its > instantaneous declaration. Using a name often used in a different context > does not change the declared type in the declaration to the type of the > symbol name you have subverted. > Agreed. Reusing a name is not bad. Just potentially confusing to people who lack experience. I am not saying don't correct the misunderstanding. I'm saying it can be done effectively along the lines of "argv in this context does not mean the same thing as it does int 'int main(int argc, char** argv); in this case argv is of type blah**". I remember back in the dark ages, pre ANSI-C, learning the language and having the hardest time with pointers. The constructs are well defined and with 26+ years of experience they are no longer a problem. At first though, I didn't understand why a function like scanf (documented to take pointers to variables) wouldn't work when I passed an actual pointer (instead of the address of a variable). My lack of experience led to an invalid conclusion. Fortunately, when I went to my TA to ask for help, he patiently explained to me the relationship between pointer variables and the address operator and why I needed "int var; scanf("%d", &var);" instead of "int* var; scanf("%d", var);". In this case, the original poster said "I don't understand why this doesn't work", and I think the obvious reason to that is inexperience (at the very least inexperience with SQLite). Then the statement "I don't understand why you expected nonsense to work", which I think is because (perhaps) too much experience! It can be hard for us "old timers" to remember what it was like back in the day when everything was new and confusing. -- Scott Robison _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users