Re: Lists, Arrays and Vectors [was Re: [Gimp-developer] Re: Tiny-Fu: A new plug-in for GIMP]

2004-07-12 Thread Sven Neumann
Hi,

Kevin Cozens [EMAIL PROTECTED] writes:

 Script-Fu scripts written for GIMP 1.2 won't work under GIMP 2.x
 without some changes due mainly to differences in the API. In what
 version of GIMP would it be possible to have the compatibility
 features of Tiny-Fu removed?

The next time we release a version that doesn't guarantee backward
compatibility. This will most probably be called GIMP 3.0 then.


Sven

___
Gimp-developer mailing list
[EMAIL PROTECTED]
http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-developer


Re: Lists, Arrays and Vectors [was Re: [Gimp-developer] Re: Tiny-Fu: A new plug-in for GIMP]

2004-07-10 Thread Sven Neumann
Hi,

Kevin Cozens [EMAIL PROTECTED] writes:

 I don't really want a compatibility-switch. Instead, old Script-Fu
 scripts should be updated so they do things the way they are supposed
 to be done in Scheme rather than how the old SIOD interpreter let
 script writers get away with some things (ie. not defining
 variables). It forces a review of the code. For example, I noticed
 that one script defined an internal routine to compute a least common
 multiple rather. I deleted the routine and used the standard Scheme
 routine 'lcm'.

I understand your reasons but a compatibility mode (if that is
feasible at all) would allow us to ditch Script-Fu in favor of
Tiny-Fu. If no such mode is available we will have to continue to ship
Script-Fu for quite a while. I don't think we can just tell people
that all their scripts won't work any longer when they update GIMP the
next time.


Sven
___
Gimp-developer mailing list
[EMAIL PROTECTED]
http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-developer


Re: Lists, Arrays and Vectors [was Re: [Gimp-developer] Re: Tiny-Fu: A new plug-in for GIMP]

2004-07-10 Thread Kevin Cozens
At 06:00 AM 07/10/2004, Sven wrote:
Kevin Cozens [EMAIL PROTECTED] writes:
 I don't really want a compatibility-switch. Instead, old Script-Fu
 scripts should be updated so they do things the way they are supposed
 to be done in Scheme rather than how the old SIOD interpreter let
 script writers get away with some things (ie. not defining
 variables).
I understand your reasons but a compatibility mode (if that is
feasible at all) would allow us to ditch Script-Fu in favor of
Tiny-Fu. If no such mode is available we will have to continue to ship
Script-Fu for quite a while.
Many (most?) of the needed changes between SIOD and TinyScheme could be 
handled via a set of additional define statements in a separate file 
included from the main TinyScheme init file. Handling the while loop should 
be possible but that requires a non-trivial Scheme define. All of these 
additional defines should be flagged in documentation as deprecated.

That just leaves the problem of variables used in a set! statement which 
are not defined before first use. Tiny-Fu displays an error message stating 
unbound variable along with the name of the variable when this situation 
is encountered. The solution is to add a line to the let block with the 
name of the variable in parenthesis (no initial value is required). A few 
of the standard Script-Fu scripts had a define that used set! but no let 
statement so a let had to be added first. I don't see how this can be 
handled automatically without a change to TinyScheme itself.

Script-Fu scripts written for GIMP 1.2 won't work under GIMP 2.x without 
some changes due mainly to differences in the API. In what version of GIMP 
would it be possible to have the compatibility features of Tiny-Fu removed?

Cheers!
Kevin.  (http://www.interlog.com/~kcozens/)
Owner of Elecraft K2 #2172|What are we going to do today, Borg?
E-mail:kcozens at interlog dot com|Same thing we always do, Pinkutus:
Packet:[EMAIL PROTECTED]|  Try to assimilate the world!
#include disclaimer/favourite   |  -Pinkutus  the Borg
___
Gimp-developer mailing list
[EMAIL PROTECTED]
http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-developer


Re: Lists, Arrays and Vectors [was Re: [Gimp-developer] Re: Tiny-Fu: A new plug-in for GIMP]

2004-07-09 Thread Markus Triska
 By using vectors I was able to very quickly update the portion of those
 scripts which used SIOD array functions. I have not changed the Tiny-Fu
 marshalling code yet but I will do that soon and release a new tarball.

Now since there is essentially a one-to-one correspondence between Tiny-Fu's 
vectors and Script-Fu's arrays, it might be worth considering adding 
compatibility definitions to init.scm (similar to gimpcompat.h for 
plug-ins), that would, depending on a certain compatibility-switch in a 
configuration file (or in init.scm itself, but I don't know if every user 
will get a copy or you will install the file in /usr/gimpsomething...), 
define  the current array operations and map them to corresponding 
vector functions. You could then (depending on said switch) also re-define 
set! to use define if a variable is not defined?.


Markus.
___
Gimp-developer mailing list
[EMAIL PROTECTED]
http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-developer


Re: Lists, Arrays and Vectors [was Re: [Gimp-developer] Re: Tiny-Fu: A new plug-in for GIMP]

2004-07-09 Thread Kevin Cozens
At 01:38 PM 07/09/2004, you wrote:
Now since there is essentially a one-to-one correspondence between Tiny-Fu's
vectors and Script-Fu's arrays, it might be worth considering adding
compatibility definitions to init.scm (similar to gimpcompat.h for
plug-ins), that would, depending on a certain compatibility-switch in a
configuration file (or in init.scm itself, but I don't know if every user
will get a copy or you will install the file in /usr/gimpsomething...),
define  the current array operations and map them to corresponding
vector functions. You could then (depending on said switch) also re-define
set! to use define if a variable is not defined?.
I don't really want a compatibility-switch. Instead, old Script-Fu 
scripts should be updated so they do things the way they are supposed to be 
done in Scheme rather than how the old SIOD interpreter let script writers 
get away with some things (ie. not defining variables). It forces a review 
of the code. For example, I noticed that one script defined an internal 
routine to compute a least common multiple rather. I deleted the routine 
and used the standard Scheme routine 'lcm'.

I am planning on putting together a Perl script that will take a Script-Fu 
script and update as much of it as possible for use with Tiny-Fu. I know of 
quite a few mappings from SIOD to TinyScheme that can be applied. 
Pre-defining variables and changing while loops to do loops will still have 
to be done by hand.

Cheers!
Kevin.  (http://www.interlog.com/~kcozens/)
Owner of Elecraft K2 #2172|What are we going to do today, Borg?
E-mail:kcozens at interlog dot com|Same thing we always do, Pinkutus:
Packet:[EMAIL PROTECTED]|  Try to assimilate the world!
#include disclaimer/favourite   |  -Pinkutus  the Borg
___
Gimp-developer mailing list
[EMAIL PROTECTED]
http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-developer


Re: Lists, Arrays and Vectors [was Re: [Gimp-developer] Re: Tiny-Fu: A new plug-in for GIMP]

2004-07-08 Thread Kevin Cozens
At 08:09 PM 07/07/2004, Markus Triska wrote:
I also opt for vector because apart from being the natural Scheme equivalent
to PDB's one-dimensional arrays, it makes writing plug-ins easier for people
that have no to little practice in converting common for/while loops using
tail-recursion, and current scripts would work practically unmodified,
without explicit conversions list-vector that would only cost time (with
everybody ending up calling these instead of working on lists most of the
time).
By using vectors I was able to very quickly update the portion of those 
scripts which used SIOD array functions. I have not changed the Tiny-Fu 
marshalling code yet but I will do that soon and release a new tarball.

Cheers!
Kevin.  (http://www.interlog.com/~kcozens/)
Owner of Elecraft K2 #2172|What are we going to do today, Borg?
E-mail:kcozens at interlog dot com|Same thing we always do, Pinkutus:
Packet:[EMAIL PROTECTED]|  Try to assimilate the world!
#include disclaimer/favourite   |  -Pinkutus  the Borg
___
Gimp-developer mailing list
[EMAIL PROTECTED]
http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-developer


Lists, Arrays and Vectors [was Re: [Gimp-developer] Re: Tiny-Fu: A new plug-in for GIMP]

2004-07-07 Thread Shlomi Fish
On Wednesday 07 July 2004 05:05, Kevin Cozens wrote:
 On Tue, 2004-07-06 at 19:45, Sven Neumann wrote:
  The fact that the PDB uses arrays doesn't necessarily mean that a
  language binding such as Tiny-Fu needs to represent them as arrays.
  One of the most annoying bits of Script-Fu is that it forces you to
  work with arrays even though the natural choice for a scheme dialekt
  would be lists. If Tiny-Fu cannot provide backward-compatibility, then
  it should overcome this mistake and map the PDB API to lists.

 Tiny-Fu makes no attempt to provide backwards compatability with the
 SIOD Scheme interpreter way of doing things. It expects scripts to
 follow the current Scheme standard as defined in the R5RS document.

 Since the R5RS does not define an array type, any script which uses
 arrays either internally or when dealing with PDB calls needs to be
 modified to use a list. The marshalling code of Tiny-Fu converts between
 PDB *ARRAY and Scheme lists as needed. The alternative would be to use a
 Scheme vector but instead of a list. Using a list seemed like the
 simplest approach.

Are you sure using lists instead of vectors is the right thing to do? Lists 
are linked lists and as such accessing the i'th element is O(i). In vectors 
it is O(1). This can cause an order of complexity increase in handling them.

Are you certain that all the scripts initialize the arrays, one element after 
another in sequential order? Or are there scripts with random access?

In any case, this may not be an issue, because a programmer can temporarily 
use a vector, and convert it to a list before calling the PDB entries.

(It reminds me that in Visual Basic the built-in array is implemented as a 
linked list, and so random access to it is slow as hell. What serious 
programmers do is implement the array logic in C and bind it to their VB 
programs)

Regards,

Shlomi Fish
-- 

-
Shlomi Fish  [EMAIL PROTECTED]
Homepage:http://shlomif.il.eu.org/

Knuth is not God! It took him two days to build the Roman Empire.
___
Gimp-developer mailing list
[EMAIL PROTECTED]
http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-developer


Re: Lists, Arrays and Vectors [was Re: [Gimp-developer] Re: Tiny-Fu: A new plug-in for GIMP]

2004-07-07 Thread Kevin Cozens
At 05:17 AM 07/07/2004, Shlomi Fish wrote:
Are you sure using lists instead of vectors is the right thing to do? Lists
are linked lists and as such accessing the i'th element is O(i). In vectors
it is O(1). This can cause an order of complexity increase in handling them.
No, I'm not sure. For the few scripts I looked at (and for ease of 
implementation), using a list was the easier route to have something 
functional during the early development stages. Using vectors instead of a 
simple list would mean the ability to use functions which would provide 
rough equivalents to the SIOD interpreters array manipulation functions.

In any case, this may not be an issue, because a programmer can temporarily
use a vector, and convert it to a list before calling the PDB entries.
Conversion is simple through the use of vector-list and list-vector.
I will take a closer look at using vectors. It will simplify the work 
needed to update old Script-Fu scripts for use with Tiny-Fu. I will start 
by converting between list and vector. If the approach works well, I will 
bit the bullet and update the marshalling code to use vectors for the 
*ARRAY types.

Cheers!
Kevin.  (http://www.interlog.com/~kcozens/)
Owner of Elecraft K2 #2172|What are we going to do today, Borg?
E-mail:kcozens at interlog dot com|Same thing we always do, Pinkutus:
Packet:[EMAIL PROTECTED]|  Try to assimilate the world!
#include disclaimer/favourite   |  -Pinkutus  the Borg
___
Gimp-developer mailing list
[EMAIL PROTECTED]
http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-developer


Re: Lists, Arrays and Vectors [was Re: [Gimp-developer] Re: Tiny-Fu: A new plug-in for GIMP]

2004-07-07 Thread Markus Triska

 Are you sure using lists instead of vectors is the right thing to do?
  Lists are linked lists and as such accessing the i'th element is O(i). In
  vectors it is O(1). This can cause an order of complexity increase in
  handling them.

This is true, but not much of a problem, since most scripts only use either 
the first 1 or 2 elements of arrays or work on typically very short arrays, 
or want to pass a (short) array to PDB, where there is no difference between 
list-construction and setting every element of a vector explicitly (the 
latter possibly being even more inefficient).

 No, I'm not sure. For the few scripts I looked at (and for ease of
 implementation), using a list was the easier route to have something
 functional during the early development stages. Using vectors instead of a
 simple list would mean the ability to use functions which would provide
 rough equivalents to the SIOD interpreters array manipulation functions.

As I understand it, there are even *exact* equivalents to the current array 
type. No wonder, since a Lisp vector is a special case of an array 
(one-dimensional). In Script-Fu, arrays are indeed vectors.

 I will take a closer look at using vectors. It will simplify the work
 needed to update old Script-Fu scripts for use with Tiny-Fu. I will start
 by converting between list and vector. If the approach works well, I will
 bit the bullet and update the marshalling code to use vectors for the
 *ARRAY types.

I also opt for vector because apart from being the natural Scheme equivalent 
to PDB's one-dimensional arrays, it makes writing plug-ins easier for people 
that have no to little practice in converting common for/while loops using 
tail-recursion, and current scripts would work practically unmodified, 
without explicit conversions list-vector that would only cost time (with 
everybody ending up calling these instead of working on lists most of the 
time).

Markus.
___
Gimp-developer mailing list
[EMAIL PROTECTED]
http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-developer