On Sun, 27 May 2001, Guillermo S. Romero / Familia Romero wrote: > Hi: > > I read the elisp rules as inspiration, and here is what I think we > should do with Scheme scripts, comments / doubts with []: > > - use prefixes for your own functions, so you avoid problems. [does > Gimp's Scheme provide "encapsulation"? if not, this is a must] > Actually, I believe every Gimp-Fu script is encapsulated but I'm not sure. In any case, using prefixes is a good idea. > - indent in Emacs style, with spaces instead of tabs. [maybe we should > provide pointers to indent apps that do it, not everybody has Emacs. > Also instructions for common editor, like vim] > I use spaces to indent, because that's how I configured my editor (gvim). However, some other users may use tabs, and I don't see anything wrong with that. > - put "(" & ")" in the same line that "text", not alone in other > lines. > I personally dislike the usual: (define (myfunc a) (if (> a 0) (sqrt a) (sqrt (- 0 a)))) style which puts all the ")"'s on the last line. I prefer C-like style like that: (define (myfunc a) (if (> a 0) (sqrt a) (sqrt (- 0 a)) ) ) I once sent a message to a mailing-list, I'm a member of, asking why the Scheme style was not indeed so. The reply I received did not convince me that it was a good idea. You can find it at: http://groups.yahoo.com/group/hackers-il/message/500 > - cut lines that are longer than 80. [70?] > I normally indent even expressions. For instance, the pythagoras theorem becomes: (sqrt (+ (* a a) (* b b) ) ) In any case, if your lines get too long, one should probably out-source part of the code as a different function. Most Script-Fu scripts are almost completely linear so it's not a very big concern. > - write documentation strings, so the PDB can show something. And > something useful, not "no info yet". > This is a good idea. I believe I followed it for my "Bugs in a square" script. Check: http://t2.technion.ac.il/~shlomif/MathVentures/bug_square.html Do you want not to accept scripts that do not follow this regulation? > - for comments use ";" (right), ";;" (code level), ";;;" (left) and > ";;;;" (left, separate areas of file). > > - first line of files ";;; filename --- one line description". > > - one blank line, and third ";; Copyright (C) the owner" (the script > owner(s), not the Gimp owner). > > - license, with the blank lines as separation. > > - another blank line, and headers like ";; header: content". See > http://www.gnu.org/manual/elisp-manual-20-2.5/html_node/elisp_657.html > for the list. [put here the list] > > - end files with ";;; filename ends here" > > - do not add "Copyright" to the copyright field in the register > function, it look weird to see "Copyright: Copyright (C) owner". > > - the path, if the script launchs a dialog, must end with "...", if > automatic action, do not put "...". [people complain about UI, no? so > start applying this basic concept] > > - data format as yyyy-mm-dd. Fill with "x" if unknown (2001-05-xx), > but only if applicable (Copyright is yyyy, not yyyy-xx-xx). > > - add "_" before strings, so can they be translated. > > - provide nice ranges for variables, all that will work, not more (it > could cause errors), not less (just cos the effect looks weird too > big, does not mean it can not be used as base for other thing). > > - provide sane defaults, at least for normal uses. Take the common > cases and apply the script. If a script to remove red eyes look poor > when you try to remove the red of a car, it is fine, but not if the > input are faces, and all them "fail". > > - use "foo" string for logos. [which string? logo name? "the gimp"?] > I'd rather people each used the string of each choice. It adds to the scripts' colour. (I really like Bovination's "Fear the Cow") > - use constant names when you call plugins, not numbers, if they exist > (DISCARD is better than 1). Look script-fu-constants.c for them. > [include a list?] > A must I believe, because they may change in future version. > Make a pointer to elisp doc, so we give credit about inspiration. > Explain why, so everyone knows it (the draft is too short). Put it in > CVS and Gimp site (aka this can be one of the test docs for the new > system). > > I am not a Scheme guru at all, so I guess I have put something stupid > or miss a basic item. I would like to see comments from Scheme people, > or lisp users in general. > Script-Fu has the advantage of being easier to compile than the other scripting interfaces. However, for most practical reasons, I believe I would prefer scripting with perl, because I can do everything perl does in Gimp-Perl scripts. (files, sockets, CPAN modules and all) Script-Fu uses SIOD, which is not an R4RS compatible Scheme implementation. (For instance, "set!" can create a new variable). Does anybody know what became of the guile bindings? Regards, Shlomi Fish > Fixes? Changes? Who decides? > > GSR > > _______________________________________________ > Gimp-developer mailing list > Gimp-developer@xxxxxxxxxxxxxxxxxxxxxx > http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-developer > ---------------------------------------------------------------------- Shlomi Fish shlomif@xxxxxxxxxxxxxxxxxxx Home Page: http://t2.technion.ac.il/~shlomif/ Home E-mail: shlomif@xxxxxxxxxx A more experienced programmer does not make less bugs. He just realizes what went wrong more quickly.