From: Ben B. <ba...@de...> - 2003-06-26 01:04:18
|
Hi. > > On the other hand, if the variables were public, > > there would be even less java-functions (e.g. > > setReadlineVar(INHIBIT_COMPLETION,INHIBIT_COMPLETION_TRUE)) > > This solution looks nicer to me, but then again that's just me. > Although I'd be tempted to use java native types for the values, e.g., > > setReadlineVar(INHIBIT_COMPLETION, true) > > These should be easy to convert in the .c file in the few cases where > the compiler doesn't do it automatically. I wouldn't mind having this working well before debian 3.1 is released, since I'd then like to update jython to use these patches and so on, with the ultimate aim for jython users to be able to use tabs at the jython command prompt. If you like I'd be happy to implement this, as either: (1) void setReadlineIntVar(int which_variable, int value); int getReadlineIntVar(int which_variable); void setReadlineStrVar(int which_variable, String value); String getReadlineStrVar(int which_variable); public static final int INHIBIT_COMPLETION; public static final int BASIC_QUOTE_CHARACTERS; (etc etc) (The rationale for splitting into int and str routines is because even though you could potentially overload setReadlineVar(), you could not overload getReadlineVar() in this way.) or (2) void setReadlineVar(IntVar which_variable, int value); void setReadlineVar(StrVar which_variable, String value); int getReadlineVar(IntVar which_variable); String getReadlineVar(StrVar which_variable); public static final IntVar INHIBIT_COMPLETION; public static final StrVar BASIC_QUOTE_CHARACTERS; (etc etc) This solution allows the single getReadlineVar() / setReadlineVar() syntax to be used, and the user need not even know about the different type-specific classes IntVar, StrVar, etc.: setReadlineVar(INHIBIT_COMPLETION, true); The IntVar and StrVar classes are empty classes that simply allow the compiler to handle the overloading of getReadlineVar() with different return types. My preferred solution is (2), simply because it's simpler from the user's point of view. Is this okay with you? Ben. |
From: Bernhard B. <ma...@ba...> - 2003-06-26 08:15:51
|
Hi Ben, I have it on my todo list, but to be honest: currently it's summer and it's hot and so I have trouble to discipline myself and sit in front of my computer. So please go ahead and implement it - it would take another few weeks for me. I have a third alternative: void setVar(int which_variable, int value); void setVar(String which_variable, String value); int getVar(int which_variable); String getVar(String which_variable); public static final int INHIBIT_COMPLETION = 1; public static final String BASIC_QUOTE_CHARACTERS = "2"; etc. which_variable is always a symbolic constant, so the user won't care if it's an int or a string. If fact, it is your solution (2) with IntVar==int, and StrVar==String. I have no objections using setReadlineVar()... if you prefer more verbose method-names. Bernhard > If you like I'd be happy to implement this, as either: > > or > > (2) > void setReadlineVar(IntVar which_variable, int value); > void setReadlineVar(StrVar which_variable, String value); > int getReadlineVar(IntVar which_variable); > String getReadlineVar(StrVar which_variable); > > public static final IntVar INHIBIT_COMPLETION; > public static final StrVar BASIC_QUOTE_CHARACTERS; > (etc etc) > > This solution allows the single getReadlineVar() / setReadlineVar() > syntax to be used, and the user need not even know about the different > type-specific classes IntVar, StrVar, etc.: > > setReadlineVar(INHIBIT_COMPLETION, true); > > The IntVar and StrVar classes are empty classes that simply allow the > compiler to handle the overloading of getReadlineVar() with different > return types. > > My preferred solution is (2), simply because it's simpler from the user's > point of view. Is this okay with you? > > Ben. |
From: Bernhard B. <ma...@ba...> - 2003-06-27 16:46:40
|
Ok, your points are correct. I was more thinking about the implementation of the native code, which is easier with standard types. There you have to map every constant to a readline/editline variable, which should be quite simple with a lookup-table. The numeric constant (resp. the string constant after a atoi-conversion) would just be an index into an array. Bernhard > > void setVar(int which_variable, int value); > > void setVar(String which_variable, String value); > > int getVar(int which_variable); > > String getVar(String which_variable); > > Using setVar() and getVar() works for me. Using string constants for > variable names does seem a little unclean though, simply because string > comparisons aren't as clean as integer or pointer comparisons. > > The suggestion of IntVar and StrVar was for cleanness and consistency. > If you're using strings then you either compare with String.equalTo() > which is inconsistent with integer comparison, or you compare with == > in which case you're doing pointer comparisons and you might as well not > assign values to the strings at all. > > Using IntVar and StrVar also avoids problems of implicit conversion if > (for instance) we later add character variables or whatever; you can > implicitly convert (char which_variable) to (int which_variable) but not > (CharVar which_variable) to (IntVar which_variable), which means it's a > little safer in the long run. > > The user of course doesn't even need to know that the IntVar and StrVar > classes exist; they simply call getVar(INHIBIT_COMPLETION) or whatever. > > Anyway, it should be relatively straightforward to change from one > implementation to the other, without affecting the use of the library at > all. > > b. |