 |
 |
|
 |
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Hello. I'm interested in inserting a certain operation into GIMP (resize to X
pixels). I'm sure I could figure out the way to achieve this functionality if
I knew GIMP's terminology for such.
Can someone educate me on what GIMP calls this kind of thing, if it were to have
it?
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: nemesis
Subject: Re: GIMP hotkeys/ scripts/ user-defined functions?
Date: 9 Dec 2008 16:20:05
Message: <493ee105@news.povray.org>
|
|
 |
|  |
|  |
|
 |
gregjohn escreveu:
> Hello. I'm interested in inserting a certain operation into GIMP (resize to X
> pixels). I'm sure I could figure out the way to achieve this functionality if
> I knew GIMP's terminology for such.
>
> Can someone educate me on what GIMP calls this kind of thing, if it were to have
> it?
You can try Filters -> Script-Fu -> Console. I think all of Gimp's API
is available in this way. It has a very handy procedure browser, with
documentation and a search box. For instance, searching for resi
already gives 2 functions for image resizing and 2 for layer resizing.
It's Gimp's default scripting language, a TinyScheme interpreter. Don't
feel terrified, Scheme is a very easy language and in any case you'll
be using it just to call functions. Syntax is simple: (function-name
par1 par2 par3 ...). That's it, the name of the function is the first
thing in the procedure call and it comes inside the parentheses.
Hope that helps.
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Mueen Nawaz
Subject: Re: GIMP hotkeys/ scripts/ user-defined functions?
Date: 9 Dec 2008 19:04:35
Message: <493f0793$1@news.povray.org>
|
|
 |
|  |
|  |
|
 |
nemesis wrote:
> It's Gimp's default scripting language, a TinyScheme interpreter. Don't
> feel terrified, Scheme is a very easy language and in any case you'll
> be using it just to call functions. Syntax is simple: (function-name
> par1 par2 par3 ...). That's it, the name of the function is the first
> thing in the procedure call and it comes inside the parentheses.
Also, Gimp has supported scripting via Python for a long time now, and
I heard that they consider it the official scripting language now.
--
It's not hard to meet expenses, they're everywhere.
/\ /\ /\ /
/ \/ \ u e e n / \/ a w a z
>>>>>>mue### [at] nawaz org<<<<<<
anl
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Mueen Nawaz wrote:
> nemesis wrote:
>> It's Gimp's default scripting language, a TinyScheme interpreter. Don't
>> feel terrified, Scheme is a very easy language and in any case you'll
>> be using it just to call functions. Syntax is simple: (function-name
>> par1 par2 par3 ...). That's it, the name of the function is the first
>> thing in the procedure call and it comes inside the parentheses.
>
> Also, Gimp has supported scripting via Python for a long time now, and
> I heard that they consider it the official scripting language now.
It's truly irrelevant the choice of language when all you really do is
just call procedures.
But anyway, Script-Fu is TinyScript and comes builtin with Gimp because
it's a really small and lightweight interpreter. I didn't see any
Python-Fu in the Win build, though it's here in my Ubuntu Gimp.
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Mike Raiford
Subject: Re: GIMP hotkeys/ scripts/ user-defined functions?
Date: 10 Dec 2008 08:32:19
Message: <493fc4e3@news.povray.org>
|
|
 |
|  |
|  |
|
 |
nemesis wrote:
> But anyway, Script-Fu is TinyScript and comes builtin with Gimp because
> it's a really small and lightweight interpreter. I didn't see any
> Python-Fu in the Win build, though it's here in my Ubuntu Gimp.
Didn't Gimp use some form of Lisp at some point? I remember it being a
PITA to write a simple macro...
--
~Mike
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Mike Raiford escreveu:
> nemesis wrote:
>
>> But anyway, Script-Fu is TinyScript and comes builtin with Gimp
>> because it's a really small and lightweight interpreter. I didn't see
>> any Python-Fu in the Win build, though it's here in my Ubuntu Gimp.
>
> Didn't Gimp use some form of Lisp at some point? I remember it being a
> PITA to write a simple macro...
Sorry, I wrote it wrong the second time: it's TinyScheme, not TinyScript.
Yes, Scheme is a Lisp dialect. No, I quite don't understand why it'd be
such a PITA. :)
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Mike Raiford
Subject: Re: GIMP hotkeys/ scripts/ user-defined functions?
Date: 10 Dec 2008 09:50:30
Message: <493fd736$1@news.povray.org>
|
|
 |
|  |
|  |
|
 |
nemesis wrote:
> Yes, Scheme is a Lisp dialect. No, I quite don't understand why it'd be
> such a PITA. :)
Something about dozens of parenthesis...
--
~Mike
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Invisible
Subject: Re: GIMP hotkeys/ scripts/ user-defined functions?
Date: 10 Dec 2008 10:02:38
Message: <493fda0e$1@news.povray.org>
|
|
 |
|  |
|  |
|
 |
>> Yes, Scheme is a Lisp dialect. No, I quite don't understand why it'd
>> be such a PITA. :)
>
> Something about dozens of parenthesis...
(if (= 1 x) (lambda (n) (1)) (lambda (n) (+ 1 n)))
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: nemesis
Subject: Re: GIMP hotkeys/ scripts/ user-defined functions?
Date: 10 Dec 2008 10:18:44
Message: <493fddd4@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Mike Raiford escreveu:
> nemesis wrote:
>
>> Yes, Scheme is a Lisp dialect. No, I quite don't understand why it'd
>> be such a PITA. :)
>
> Something about dozens of parenthesis...
Most of it are procedure calls and would need parentheses in most
languages anyway. At least, no colons between parameters are needed. ;)
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Invisible escreveu:
>>> Yes, Scheme is a Lisp dialect. No, I quite don't understand why it'd
>>> be such a PITA. :)
>>
>> Something about dozens of parenthesis...
>
> (if (= 1 x) (lambda (n) (1)) (lambda (n) (+ 1 n)))
I don't really think someone scripting Gimp needs lambdas. And your
first lambda will fail because 1 is not a function, but you've put it in
calling context as the first element of a list.
Other than that, "if" is as straightforward as in any language.
(if condition
this
that)
or just
(if condition this)
Actually, the "if-then-else" statement was born in Lisp.
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Invisible
Subject: Re: GIMP hotkeys/ scripts/ user-defined functions?
Date: 10 Dec 2008 10:31:32
Message: <493fe0d4$1@news.povray.org>
|
|
 |
|  |
|  |
|
 |
>> Something about dozens of parenthesis...
>
> Most of it are procedure calls and would need parentheses in most
> languages anyway. At least, no colons between parameters are needed. ;)
Bah! And people complain because Haskell allows you to write simple
expressions with no punctuation at all... :-P
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Invisible
Subject: Re: GIMP hotkeys/ scripts/ user-defined functions?
Date: 10 Dec 2008 10:32:56
Message: <493fe128$1@news.povray.org>
|
|
 |
|  |
|  |
|
 |
>> (if (= 1 x) (lambda (n) (1)) (lambda (n) (+ 1 n)))
>
> I don't really think someone scripting Gimp needs lambdas.
You would *hope* not...
(OTOH, does the GIMP allow you to use arbitrary lambda functions for
tone mapping? That could be useful!)
> Actually, the "if-then-else" statement was born in Lisp.
Really? You have proof of that?
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: nemesis
Subject: Re: GIMP hotkeys/ scripts/ user-defined functions?
Date: 10 Dec 2008 10:37:14
Message: <493fe22a@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Invisible escreveu:
>> Actually, the "if-then-else" statement was born in Lisp.
>
> Really? You have proof of that?
http://en.wikipedia.org/wiki/Lisp_(programming_language)#Language_innovations
Not that wikipedia is authorithative knowledge... :P
Until then, all you had was assembly branching.
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Mike Raiford
Subject: Re: GIMP hotkeys/ scripts/ user-defined functions?
Date: 10 Dec 2008 10:57:11
Message: <493fe6d7@news.povray.org>
|
|
 |
|  |
|  |
|
 |
nemesis wrote:
> Most of it are procedure calls and would need parentheses in most
> languages anyway. At least, no colons between parameters are needed. ;)
Not so much that, but rather the deep nesting that gets to me..
--
~Mike
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Invisible
Subject: Re: GIMP hotkeys/ scripts/ user-defined functions?
Date: 10 Dec 2008 10:59:51
Message: <493fe777$1@news.povray.org>
|
|
 |
|  |
|  |
|
 |
>> Most of it are procedure calls and would need parentheses in most
>> languages anyway. At least, no colons between parameters are needed. ;)
>
> Not so much that, but rather the deep nesting that gets to me..
This is why Haskell allows you to take
foo1(foo2(foo3(foo4(foo5(foo6(x))))))
and rewrite it as
foo1 $ foo2 $ foo3 $ foo4 $ foo5 $ foo6 x
;-)
(Otherwise, you'd need a special editor which counts the number of
brackets for you to make sure they actually match up!)
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Invisible
Subject: Re: GIMP hotkeys/ scripts/ user-defined functions?
Date: 10 Dec 2008 11:07:48
Message: <493fe954$1@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Hmm... let's see that in visuals...
C / C++ / C# / Java / JavaScript / ** YOU LANGUAGE HERE FOR £5/MONTH **:
foo(1, 2, 3, 4, 5, 6, 7, 8);
Lisp:
(foo 1 2 3 4 5 6 7 8)
Haskell:
foo 1 2 3 4 5 6 7 8
...and the award for fewest characters required to express a simple idea
goes to: Haskell. ;-)
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: nemesis
Subject: Re: GIMP hotkeys/ scripts/ user-defined functions?
Date: 10 Dec 2008 11:18:48
Message: <493febe8@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Invisible escreveu:
>> Not so much that, but rather the deep nesting that gets to me..
You can break down in separate procedures/functions if you prefer. But
deep nesting with anonymous functions is a hallmark of functional
languages...
> This is why Haskell allows you to take
>
> foo1(foo2(foo3(foo4(foo5(foo6(x))))))
>
> and rewrite it as
>
> foo1 $ foo2 $ foo3 $ foo4 $ foo5 $ foo6 x
Haven't we gone through this before?
(define (compose f g . fs)
(if (null? fs) (lambda (x) (f (g x)))
(apply compose (lambda (x) (f (g x))) (car fs) (cdr fs))))
(define o compose)
(define (inc n) (+ 1 n))
(define (sqr n) (* n n))
(o inc sqr inc) ; returns a procedure, which you may store somewhere and
later reuse
((o inc sqr inc) 3) ; applies the procedure to argument 3
so, you're example would be:
((o foo1 foo2 foo3 foo4 foo5 foo6) x)
foo1 $ foo2 $ foo3 $ foo4 $ foo5 $ foo6 x
whoa! It's shorter! ;)
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Darren New
Subject: Re: GIMP hotkeys/ scripts/ user-defined functions?
Date: 10 Dec 2008 11:21:18
Message: <493fec7e$1@news.povray.org>
|
|
 |
|  |
|  |
|
 |
nemesis wrote:
> (o inc sqr inc)
This level of notation, without the parens, is where I always get lost
trying to understand SML. The presence of parens shows what's an argument
and what's a function, in ways that mixing binary and unary operators that
are spelled the same way as variables doesn't.
--
Darren New, San Diego CA, USA (PST)
The NFL should go international. I'd pay to
see the Detroit Lions vs the Roman Catholics.
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: nemesis
Subject: Re: GIMP hotkeys/ scripts/ user-defined functions?
Date: 10 Dec 2008 11:25:39
Message: <493fed83@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Invisible escreveu:
> Lisp:
> (foo 1 2 3 4 5 6 7 8)
>
> Haskell:
> foo 1 2 3 4 5 6 7 8
>
>
> ...and the award for fewest characters required to express a simple idea
> goes to: Haskell. ;-)
Actually, that example should be perfect for Python/Ruby and their's
named arguments. 8 friggin' arguments is impossible to remember which
is which! They beat both Haskell and Lisp hands down... :)
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Invisible
Subject: Re: GIMP hotkeys/ scripts/ user-defined functions?
Date: 10 Dec 2008 11:27:18
Message: <493fede6@news.povray.org>
|
|
 |
|  |
|  |
|
 |
>>> Not so much that, but rather the deep nesting that gets to me..
>
> You can break down in separate procedures/functions if you prefer. But
> deep nesting with anonymous functions is a hallmark of functional
> languages...
I would say that if you find yourself needing to nest things *too*
deeply, you're doing something wrong.
>> This is why Haskell allows you to take
>>
>> foo1(foo2(foo3(foo4(foo5(foo6(x))))))
>>
>> and rewrite it as
>>
>> foo1 $ foo2 $ foo3 $ foo4 $ foo5 $ foo6 x
>
> Haven't we gone through this before?
>
> (define (compose f g . fs)
> (if (null? fs) (lambda (x) (f (g x)))
> (apply compose (lambda (x) (f (g x))) (car fs) (cdr fs))))
>
> (define o compose)
>
> (define (inc n) (+ 1 n))
> (define (sqr n) (* n n))
>
> (o inc sqr inc) ; returns a procedure, which you may store somewhere and
> later reuse
>
> ((o inc sqr inc) 3) ; applies the procedure to argument 3
>
> so, you're example would be:
>
> ((o foo1 foo2 foo3 foo4 foo5 foo6) x)
> foo1 $ foo2 $ foo3 $ foo4 $ foo5 $ foo6 x
>
> whoa! It's shorter! ;)
What, defining three pages of code is longer than the 1-liner I posted?
The ($) operator is defined in the Haskell language standard. :-P
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Invisible
Subject: Re: GIMP hotkeys/ scripts/ user-defined functions?
Date: 10 Dec 2008 11:29:16
Message: <493fee5c$1@news.povray.org>
|
|
 |
|  |
|  |
|
 |
nemesis wrote:
> Actually, that example should be perfect for Python/Ruby and their's
> named arguments.
Don't forget Smalltalk. (Although Smalltalk still requires you to write
them *in the right order*.)
> 8 friggin' arguments is impossible to remember which
> is which! They beat both Haskell and Lisp hands down... :)
Yeah, actually _any_ function that requires 8 distinct arguments is
probably a bad idea. Probably means you should be splitting it into
several seperate functions, or joining some of the arguments up into
more complex data structures, or *something*...
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
nemesis escreveu:
> Actually, that example should be perfect for Python/Ruby and their's
> named arguments. 8 friggin' arguments is impossible to remember which
> is which! They beat both Haskell and Lisp hands down... :)
Hmm, actually, Common Lisp has named arguments... but I'm more of a
Scheme guy... :P
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Invisible
Subject: Re: GIMP hotkeys/ scripts/ user-defined functions?
Date: 10 Dec 2008 11:30:04
Message: <493fee8c$1@news.povray.org>
|
|
 |
|  |
|  |
|
 |
nemesis wrote:
> Hmm, actually, Common Lisp has named arguments... but I'm more of a
> Scheme guy... :P
Are you scheming against me? :-P
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: nemesis
Subject: Re: GIMP hotkeys/ scripts/ user-defined functions?
Date: 10 Dec 2008 11:30:50
Message: <493feeba@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Invisible escreveu:
>> so, you're example would be:
>>
>> ((o foo1 foo2 foo3 foo4 foo5 foo6) x)
>> foo1 $ foo2 $ foo3 $ foo4 $ foo5 $ foo6 x
>>
>> whoa! It's shorter! ;)
>
> What, defining three pages of code is longer than the 1-liner I posted?
>
> The ($) operator is defined in the Haskell language standard. :-P
The o operator is defined in my personal standard and I never look back. ;)
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: nemesis
Subject: Re: GIMP hotkeys/ scripts/ user-defined functions?
Date: 10 Dec 2008 11:32:54
Message: <493fef36@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Invisible escreveu:
> nemesis wrote:
>
>> Hmm, actually, Common Lisp has named arguments... but I'm more of a
>> Scheme guy... :P
>
> Are you scheming against me? :-P
I'll plot something... :D
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: nemesis
Subject: Re: GIMP hotkeys/ scripts/ user-defined functions?
Date: 10 Dec 2008 11:36:56
Message: <493ff028@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Darren New escreveu:
> nemesis wrote:
>> (o inc sqr inc)
>
> This level of notation, without the parens, is where I always get lost
> trying to understand SML. The presence of parens shows what's an
> argument and what's a function, in ways that mixing binary and unary
> operators that are spelled the same way as variables doesn't.
That's a problem with languages that permit such ambiguities. There
simply is no ambiguity in Lisp expressions. Also, Scheme has a single
namespace for functions and variables, so you can't have a single
identifier for both and resolve ambiguity by context. It's a remarkably
homogenous language.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
>> What, defining three pages of code is longer than the 1-liner I posted?
>>
>> The ($) operator is defined in the Haskell language standard. :-P
>
> The o operator is defined in my personal standard and I never look back. ;)
OK, but ($) is still a 1-liner:
f $ x = f x
And, unlike your notation, it doesn't require any brackets at all! ;-)
BTW, what would you say the most irritating library design flaw in
Scheme is? In Haskell, my personal one is this:
filter odd [1, 2, 3, 4]
That takes a list and filters out the odd numbers, right?
WRONG!
It filters out the *even* numbers.
Like, WTF?
Obviously what they *should* have done is name it "select". Then you
would write
select odd [1, 2, 3, 4]
and it would be completely obvious what it does. Hey, it works for SQL
and Smalltalk, why not Haskell? *sigh* I keep thinking that
filter f = select (not . f)
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Hmm, I wonder if this gregjohn fellow is taking any advantage from my
replies. He posts a question and vanishes! O_o
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
nemesis wrote:
> Hmm, actually, Common Lisp has named arguments... but I'm more of a
> Scheme guy... :P
How about this:
data Settings = Settings
{
time_step :: Time,
min_subdivide :: Time,
tolerance :: Space,
recursive :: Bool
}
foo $ Settings {recursive = True, tolerance = 0.01, min_subdivide =
0.001, time_step = 2.5}
Heh, that's the trouble with named arguments - it gets so verbose. ;-)
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Invisible
Subject: Re: GIMP hotkeys/ scripts/ user-defined functions?
Date: 10 Dec 2008 11:43:06
Message: <493ff19a$1@news.povray.org>
|
|
 |
|  |
|  |
|
 |
nemesis wrote:
> http://en.wikipedia.org/wiki/Lisp_(programming_language)#Language_innovations
>
>
> Not that wikipedia is authorithative knowledge... :P
>
> Until then, all you had was assembly branching.
...there's an XML syntax for Lisp??! o_O
*runs away*
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Invisible escreveu:
>>> What, defining three pages of code is longer than the 1-liner I posted?
>>>
>>> The ($) operator is defined in the Haskell language standard. :-P
>>
>> The o operator is defined in my personal standard and I never look
>> back. ;)
>
> OK, but ($) is still a 1-liner:
>
> f $ x = f x
>
> And, unlike your notation, it doesn't require any brackets at all! ;-)
Why would my o operator not be a one-liner? Unless you think the
implementation of $ doesn't count. It's just as abstracted away as the
implementation of o.
I don't have a problem with brackets or parenthesis. Besides, Haskell
needs it too to solve ambiguities in all but the most simpler expressions.
And multiple $ for each call is as bad as multiple parenthesis, I guess.
> BTW, what would you say the most irritating library design flaw in
> Scheme is?
None. It's perfect. ;)
Ok, to be fair, I didn't like the latest standard very much... And given
Scheme is very minimalist, I'm used to writing my own libs, so any
design flaws are really mine. ;)
> In Haskell, my personal one is this:
>
> filter odd [1, 2, 3, 4]
>
> That takes a list and filters out the odd numbers, right?
>
> WRONG!
>
> It filters out the *even* numbers.
>
> Like, WTF?
>
> Obviously what they *should* have done is name it "select". Then you
> would write
>
> select odd [1, 2, 3, 4]
Hmm, that's just different terminology for the same things. Yes, I too
would expect filter odd to return the odds, but it certainly can be seen
working the other way around. I believe, though, that 2 functions doing
pretty much the same thing is wrong and bad design. select is really
only used in SQL. filter is a pretty common functional language idiom...
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Invisible escreveu:
> data Settings = Settings
> {
> time_step :: Time,
> min_subdivide :: Time,
> tolerance :: Space,
> recursive :: Bool
> }
>
> foo $ Settings {recursive = True, tolerance = 0.01, min_subdivide =
> 0.001, time_step = 2.5}
>
> Heh, that's the trouble with named arguments - it gets so verbose. ;-)
Hah! And now you got brackets and colons (and type declarations)!!
mwahahahaaha
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Darren New
Subject: Re: GIMP hotkeys/ scripts/ user-defined functions?
Date: 10 Dec 2008 11:53:33
Message: <493ff40d@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Invisible wrote:
> Don't forget Smalltalk. (Although Smalltalk still requires you to write
> them *in the right order*.)
*And* it doesn't tell you in advance when you get it wrong. :-)
Try Ada. :-)
> Yeah, actually _any_ function that requires 8 distinct arguments is
> probably a bad idea.
For OO, you should probably be setting them as configuration-style data on
the object you're invoking. This is Bertrand Meyer's take on it, and it
makes sense to me: if you have a method in an OO language that has optional
arguments, those arguments ought to be properties on the object with setters
and getters. I think this is probably true, because 95% of the time I wind
up with optional arguments, it's because I already wrote and used the
function in a bunch of places, and now I want to pass one more argument
without tracking down all the places the original got called. Either making
it a method with a settable parameter in the instance, or actually taking
the time to track down all the calls (which can be messy in a very dynamic
language) would fix that.
For functional, I can easily imagine a main loop sort of thing having to
carry around a bunch of arguments that don't make sense to put together.
For example, I have a computer word game where the main game-engine keeps a
list of possible guesses, a list of the computer's past guesses, a list of
new words it learned this game, a list of guesses made by the player and
their associated score, the human's previous guess, the computer's previous
guess, the computer's secret work (which the human is trying to guess), the
original list of words, the connection to the UI, and the random number
seed. It's hard to believe there's any data structure that sensibly
encapsulates all that without simply being a kludge to work around the lack
of loops in the language. (With loops, you'd just make most of them local
variables and not actually have to pass them through the recursive calls.)
Mind, I'm not used to functional programming, so maybe I'm doing something
wrong...
--
Darren New, San Diego CA, USA (PST)
The NFL should go international. I'd pay to
see the Detroit Lions vs the Roman Catholics.
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: nemesis
Subject: Re: GIMP hotkeys/ scripts/ user-defined functions?
Date: 10 Dec 2008 11:58:11
Message: <493ff523@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Invisible escreveu:
> nemesis wrote:
>
>> http://en.wikipedia.org/wiki/Lisp_(programming_language)#Language_innovations
>>
>>
>> Not that wikipedia is authorithative knowledge... :P
>>
>> Until then, all you had was assembly branching.
>
> ...there's an XML syntax for Lisp??! o_O
>
> *runs away*
Holy Crap!!
actually, it's just a bridge between CL and XML. Hey, XML itself is an
s-expression language, like Lisp. ;)
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Invisible wrote:
> filter odd [1, 2, 3, 4]
> It filters out the *even* numbers.
Yes. And the odd numbers stay behind in the filter. If you filter out coffee
grounds, what do you have when you're done? Grounds, or coffee?
The problem with a real filter is it separates, rather than selects. When
you filter coffee, are you filtering the grounds or the drinkable stuff?
Neither: you're separating the two.
I'm kind of surprised "filter" doesn't return both, given it would seem
(semantically) fairly easy not to calculate whichever half doesn't get used.
--
Darren New, San Diego CA, USA (PST)
The NFL should go international. I'd pay to
see the Detroit Lions vs the Roman Catholics.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
>> filter odd [1, 2, 3, 4]
>> It filters out the *even* numbers.
>
> Yes. And the odd numbers stay behind in the filter. If you filter out
> coffee grounds, what do you have when you're done? Grounds, or coffee?
>
> The problem with a real filter is it separates, rather than selects.
> When you filter coffee, are you filtering the grounds or the drinkable
> stuff? Neither: you're separating the two.
I still prefer Smalltalk's "select" and "reject". Makes much more sense
to me. :-P
> I'm kind of surprised "filter" doesn't return both, given it would seem
> (semantically) fairly easy not to calculate whichever half doesn't get
> used.
Nope; that's "partition". (Which at least has a sensible name.)
--
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
> Why would my o operator not be a one-liner?
Because it's defined as four (very wide) lines? :-P
> I don't have a problem with brackets or parenthesis. Besides, Haskell
> needs it too to solve ambiguities in all but the most simpler expressions.
Yeah, I know. This argument is getting kinda silly. ;-)
> And multiple $ for each call is as bad as multiple parenthesis, I guess.
Not really. With brackets, you have to match opening and closing
characters. With ($), there is only one thing to "match". The trouble
comes if you try to mix it with brackets as well... Basically, if you
find yourself doing this, you should probably split your expression into
smaller parts. Same as any language, really... except Lisp. In Lisp, you
cannot avoid endless brackets, because notionally the *entire source
code* as a single expression. :-P
>> BTW, what would you say the most irritating library design flaw in
>> Scheme is?
>
> None. It's perfect. ;)
Heh, right. One question: is it statically-typed?
> Ok, to be fair, I didn't like the latest standard very much... And given
> Scheme is very minimalist, I'm used to writing my own libs, so any
> design flaws are really mine. ;)
Yeah, I prefer a language with as few things as possible "baked-in".
Sadly, Haskell's list syntax is one such thing. :-(
> Hmm, that's just different terminology for the same things.
Ah, but *never* underestimate how important terminology can be! ;-)
> I believe, though, that 2 functions doing
> pretty much the same thing is wrong and bad design.
Haskell is *loaded* with functions that do the same or similar things.
It's about how you want to think about your problem.
For example, there's a variable defined that's called "otherwise". It's
value is "True". But compare these:
foo x
| x < 0 = ...
| x == 0 = ...
| True = ...
foo x
| x < 0 = ...
| x == 0 = ...
| otherwise = ...
Which do you think is clearer? ;-)
> select is really only used in SQL.
And Smalltalk.
--
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Orchid XP v8
Subject: Re: GIMP hotkeys/ scripts/ user-defined functions?
Date: 10 Dec 2008 13:46:24
Message: <49400e80@news.povray.org>
|
|
 |
|  |
|  |
|
 |
>> ...there's an XML syntax for Lisp??! o_O
>>
>> *runs away*
>
> Holy Crap!!
>
> actually, it's just a bridge between CL and XML. Hey, XML itself is an
> s-expression language, like Lisp. ;)
More worryingly... There is also Lisp syntax for Haskell. o_O
--
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Orchid XP v8 escreveu:
>>> ...there's an XML syntax for Lisp??! o_O
>>>
>>> *runs away*
>>
>> Holy Crap!!
>>
>> actually, it's just a bridge between CL and XML. Hey, XML itself is
>> an s-expression language, like Lisp. ;)
>
> More worryingly... There is also Lisp syntax for Haskell. o_O
There is Liskell. ;)
http://liskell.org/
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Orchid XP v8 escreveu:
>> Why would my o operator not be a one-liner?
>
> Because it's defined as four (very wide) lines? :-P
By how many lines is $ defined by?
Abstract it away, man! We're here today because we stand in the
shoulders of giants, don't forget that...
> In Lisp, you
> cannot avoid endless brackets, because notionally the *entire source
> code* as a single expression. :-P
Yes, code is data in Lisp. Ain't that sweet? :)
> Heh, right. One question: is it statically-typed?
No. Like I said, perfect. :)
> Haskell is *loaded* with functions that do the same or similar things.
> It's about how you want to think about your problem.
I prefer to design my own DSLs and have a minimalist general-purpose
language with few constructs that don't get in the way nor confuse me
with conflicting semantics.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
>>> Why would my o operator not be a one-liner?
>>
>> Because it's defined as four (very wide) lines? :-P
>
> By how many lines is $ defined by?
One. (See my earlier reply.)
>> In Lisp, you cannot avoid endless brackets, because notionally the
>> *entire source code* as a single expression. :-P
>
> Yes, code is data in Lisp. Ain't that sweet? :)
>
>> Heh, right. One question: is it statically-typed?
>
> No. Like I said, perfect. :)
If it's not statically-typed, how do you know that all your types match
up correctly?
Oh yeah, that's right - you run it and hope you tested every possible
code path. Until you release the code, and 3 years later discover that
hidden away in some corner is a type mismatch.
...or you could have the compiler tell you on the day when you tried to
compile the code.
Guess which way I prefer? ;-)
>> Haskell is *loaded* with functions that do the same or similar things.
>> It's about how you want to think about your problem.
>
> I prefer to design my own DSLs and have a minimalist general-purpose
> language with few constructs that don't get in the way nor confuse me
> with conflicting semantics.
Each to their own...
--
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Orchid XP v8 escreveu:
>> By how many lines is $ defined by?
>
> One. (See my earlier reply.)
No. I suggest you go through the GHC code and discover by yourself.
> If it's not statically-typed, how do you know that all your types match
> up correctly?
Oh, *I* know. Question is: does the compiler/interpreter knows where I
want to go to? Is it assuming right my decisions?
In C++/Java I have to carefully feed such decisions to the dumb
compiler, in Haskell I have to be sure its correctly following and
inform it when it isn't -- by running into runtime type mismatches, when
the compiler incorrectly assumed something.
In Scheme/Python/Ruby, the interpreter just don't care and it's all up
to you.
> Oh yeah, that's right - you run it and hope you tested every possible
> code path. Until you release the code, and 3 years later discover that
> hidden away in some corner is a type mismatch.
Not different at all from any logic mismatch between what you want to
say and what you actually say. You may type your whole program
correctly and still have logical inconsistencies. Sure, type
inconsistencies are catched early, but they sound to me like trivial
errors. They were certainly non-trivial in C/C++ and their multitude of
pointer arithmetic, they are non-trivial in Java and its multitudes of
deep OO nestings and inter-module dependencies, and they are also
non-trivial in Haskell because of the way how its advanced and complex
type system allows for much of the behaviour of a program to be directly
embedded in the type declarations themselves.
They are trivial though in Scheme, where types are just basic data types
and simple groupings and most of the program behaviour is still
algorithmic in the traditional sense. Type mismatches are the very
minor of headaches here. So, I guess the importance of type systems is
relative.
Anyway, I don't know exactly how this discussion would fit an embedded
scripting language running in a host app. Would Haskell do any better
as an embedded scripting language? All its type safeties don't quite do
much in a non-compiled interactive environment: if you ever did
anything at a Hugs or GHCi console, you'll see you may constantly run
into runtime type errors just as in a dynamically typed language.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
>>> By how many lines is $ defined by?
>>
>> One. (See my earlier reply.)
>
> No. I suggest you go through the GHC code and discover by yourself.
Why? It's not defined in GHC, it's defined in the libraries. :-P
[Checking the language standard document, it's actually defined as two
lines, because it gives a type signature as well.]
>> If it's not statically-typed, how do you know that all your types
>> match up correctly?
>
> Oh, *I* know.
Right. Sure. Because you're super-human. :-P
> In C++/Java I have to carefully feed such decisions to the dumb
> compiler, in Haskell I have to be sure its correctly following and
> inform it when it isn't -- by running into runtime type mismatches, when
> the compiler incorrectly assumed something.
In Haskell, you can't *have* runtime type mismatches. :-P
> In Scheme/Python/Ruby, the interpreter just don't care and it's all up
> to you.
Exactly. If you make a mistake, it's your fault, and the interpreter
gives you no help at all to fix it.
>> Oh yeah, that's right - you run it and hope you tested every possible
>> code path. Until you release the code, and 3 years later discover that
>> hidden away in some corner is a type mismatch.
>
> Not different at all from any logic mismatch between what you want to
> say and what you actually say. You may type your whole program
> correctly and still have logical inconsistencies.
Does the type system catch every possible problem? No.
Will any automated system ever catch every possible problem? No.
Does that mean that automated systems for catching problems are a waste
of time? Again, no.
> Anyway, I don't know exactly how this discussion would fit an embedded
> scripting language running in a host app. Would Haskell do any better
> as an embedded scripting language? All its type safeties don't quite do
> much in a non-compiled interactive environment: if you ever did
> anything at a Hugs or GHCi console, you'll see you may constantly run
> into runtime type errors just as in a dynamically typed language.
For writing small, simple things on the fly, something vague and
unstructured is probably the best way to go. (This is why scripting
languages exist.)
Personally, I don't tend to write that kind of code.
--
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Orchid XP v8 wrote:
> [Checking the language standard document, it's actually defined as two
> lines, because it gives a type signature as well.]
So is mine. The others had nothing to do with compose.
>> Oh, *I* know.
>
> Right. Sure. Because you're super-human. :-P
No, I just know what I'm doing and consider type errors too primary and
trivial next to logic errors.
> In Haskell, you can't *have* runtime type mismatches. :-P
True. Sorry. It's a type system error message from verifying a type
mismatch is happening. It is helpful.
Of course, it's also a pain in the butt when it gets in the way:
Prelude> let statusLine fruits = if fruits>1 then fruits else "No more
fruits"
<interactive>:1:34:
No instance for (Num [Char])
arising from the literal `1' at <interactive>:1:34
Possible fix: add an instance declaration for (Num [Char])
In the second argument of `(>)', namely `1'
In the predicate expression: fruits > 1
In the expression: if fruits > 1 then fruits else "No more fruits"
I used a quick hack to try to get around it:
Prelude> let self x = x
Prelude> let statusLine fruits = if fruits>1 then self statusLine fruits
else "No more fruits"
So far, so good. The compiler didn't do its job. ;)
But, then:
Prelude> print statusLine 3
<interactive>:1:0:
Couldn't match expected type `t1 -> t'
against inferred type `IO ()'
In the expression: print statusLine 3
In the definition of `it': it = print statusLine 3
I tried to group it with parenthesis then:
Prelude> print (statusLine 3)
"
Weird! It output that single double quote and froze. I had to
interrupt it.
Lesson here: sometimes the compiler not only gets in your way but also
doesn't do its job as supposed.
Oh, and BTW:
Prelude> filter odd [1,2,3,4,5]
[1,3,5]
weird, huh? :P
>> In Scheme/Python/Ruby, the interpreter just don't care and it's all up
>> to you.
>
> Exactly. If you make a mistake, it's your fault, and the interpreter
> gives you no help at all to fix it.
It gives you a nice call stack trace. :)
Seriously though, Common Lisp is king in this respect. Some of its most
well-known implementations' runtime systems allow for a quick debug of
what's going on in an app, correcting, compiling and even patching it
while the system is still running. Yes, no need for reboots.
> Does that mean that automated systems for catching problems are a waste
> of time? Again, no.
Not at all.
> For writing small, simple things on the fly, something vague and
> unstructured is probably the best way to go. (This is why scripting
> languages exist.)
Exactly. Dynamic languages fit the bill whenever specifications are
vague and prone to much change. Like, every real world system I've
worked with, except they were in horribly asinine straightjacket
languages that penalized changes.
> Personally, I don't tend to write that kind of code.
But it was the kind of which the OP was asking about.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
nemesis <nam### [at] gmail com> wrote:
> Hmm, I wonder if this gregjohn fellow is taking any advantage from my
> replies. He posts a question and vanishes! O_o
My goodness, how long has it been?!
But I did look at the Script-Fu (had to be sure I typed that right) for resize
and don't think it exactly worked.
I was hoping to do something like set up my own hotkey where like Shft Ctrl F11
just automatically resizes to 400x300 pixels.
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Nicolas Alvarez
Subject: Re: GIMP hotkeys/ scripts/ user-defined functions?
Date: 10 Dec 2008 21:36:24
Message: <49407ca8@news.povray.org>
|
|
 |
|  |
|  |
|
 |
nemesis wrote:
> actually, it's just a bridge between CL and XML. Hey, XML itself is an
> s-expression language, like Lisp. ;)
Some people have tried the opposite. Converting XML into something that
looks like lisp :)
<tag attr1="value1"
attr2="value2">
<nested>Text node</nested>
<empty/>
</tag>
(tag (@ (attr1 "value1")
(attr2 "value2"))
(nested "Text node")
(empty))
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"gregjohn" <pte### [at] yahoo com> wrote:
> I was hoping to do something like set up my own hotkey where like Shft Ctrl F11
> just automatically resizes to 400x300 pixels.
Oh, man! Why didn't you say so? We went all into a language flamewar that
could be avoided! :P
Anyway, it's in the Edit -> Preferences dialog. Go to Interface -> Config
Keyboard Shortcuts, select Image -> Resize Image (way down), press your choice
of shortcut, done.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Nicolas Alvarez <nic### [at] gmail com> wrote:
> nemesis wrote:
> > actually, it's just a bridge between CL and XML. Hey, XML itself is an
> > s-expression language, like Lisp. ;)
>
> Some people have tried the opposite. Converting XML into something that
> looks like lisp :)
>
> <tag attr1="value1"
> attr2="value2">
> <nested>Text node</nested>
> <empty/>
> </tag>
>
> (tag (@ (attr1 "value1")
> (attr2 "value2"))
> (nested "Text node")
> (empty))
Yes. Many web frameworks for Scheme go that path. And I like it much better.
:)
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
> Lesson here: sometimes the compiler not only gets in your way but also
> doesn't do its job as supposed.
In other words, "no automated system catches every possible error". :-P
That doesn't make automated error catching useless.
>>> In Scheme/Python/Ruby, the interpreter just don't care and it's all
>>> up to you.
>>
>> Exactly. If you make a mistake, it's your fault, and the interpreter
>> gives you no help at all to fix it.
>
> It gives you a nice call stack trace. :)
>
> Seriously though, Common Lisp is king in this respect. Some of its most
> well-known implementations' runtime systems allow for a quick debug of
> what's going on in an app, correcting, compiling and even patching it
> while the system is still running. Yes, no need for reboots.
Isn't that precisely what Smalltalk also does? :-P
Of course, much as I like Smalltalk, the lack of static typing makes it
really hard to use. When you have multiple levels of indirection, it's
very easy to accidentally miss one out. Static typing would instantly
detect this mistake and tell you exactly where the problem is. But
Smalltalk doesn't have it. So you run your code, something of the wrong
type gets assigned somewhere, and many hundred method calls later, you
get an exception because some method isn't defined. Oh, sure, you get a
call stack, but *good luck* figuring out where the _problem_ is. The
call stack only shows you where the problem get _detected_.
>> Does that mean that automated systems for catching problems are a
>> waste of time? Again, no.
>
> Not at all.
You see why I like having automated error-catching systems then? :-P
>> For writing small, simple things on the fly, something vague and
>> unstructured is probably the best way to go. (This is why scripting
>> languages exist.)
>
> Exactly. Dynamic languages fit the bill whenever specifications are
> vague and prone to much change.
No, scripting languages fit the bill anywhere the thing to be built is
small, simple, and it's only going to be used in one specific way.
As soon as you start trying to do anything more sophisticated than that,
scripting languages become inadaquate.
>> Personally, I don't tend to write that kind of code.
>
> But it was the kind of which the OP was asking about.
Yeah, I get that. I'm just saying, for writing large complex programs,
more help = better.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Invisible wrote:
> Isn't that precisely what Smalltalk also does? :-P
Oddly enough, Ada can unload and reload new code while it's running too, and
that's about the most anal-retentive language I've ever used.
> Of course, much as I like Smalltalk, the lack of static typing makes it
> really hard to use. [...] but *good luck* figuring out where the
> _problem_ is. The
> call stack only shows you where the problem get _detected_.
You know, I did my PhD work by patching into someone else's structured
editor/compiler/interpreter written Smalltalk, without really understanding
all the details. I had this kind of error maybe a handful of times, and it
was never confusing what happened. If you leave out a level of indirection,
then you wind up with an array of XYZ where you expected a XYZ, so you know
you missed the indirection where you wanted to go from array-of-XYZ to XYZ.
If do one too many, you get the error exactly when you ask for the Nth XYZ
from the array of XYZ that's really a single XYZ.
> As soon as you start trying to do anything more sophisticated than that,
> scripting languages become inadaquate.
I disagree.
--
Darren New, San Diego CA, USA (PST)
The NFL should go international. I'd pay to
see the Detroit Lions vs the Roman Catholics.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |