Release of G'MIC 3.1

My opinion is that if foreach will probably fit for 90% of repeat local .. endl done loops.
The remaining 10% (thousands of slight variants with reverse orders, or with multiple images in the local environment) could be still done with the repeat...done.
I’ll prefer to keep foreach as simple as possible.

I wouldn’t mind. I even thought of the possibility of having multiple parameters but I am not an expert on syntax… so no other comment from me.

That is reasonable. I thought that there is perhaps a for me unknown trick to have additional images in the foreach environment.

By the way update310.gmic is not actualized, after up I have # Generated on : 2022/03/02, 18:58!

Is there a way to redirect the user file? I have some difficulties with a ‘new’ .gmic using version 3.0.2 or older.

This using Gimp 2.10.30 (kubuntu 20.04 ) and my compile gmic 3.1.0 (static )

*** Error in ./fx_rotate_tileable/rotate_tileable/ *** Command ‘rotate_tileable’: Invalid image dimension (603,521,1,4).

All over the sections involving ‘endl’ / ‘and’
typically:
*** Error in ./samj_Angoisse/gimp_blend_1651/*if/*repeat/*local/ *** Unknown command or filename ‘endl’; did you mean ‘and’?

I do sometimes use this one.
*** Error in ./fx_bokeh/*repeat/*local/ *** Command ‘name’: Number of arguments (4) cannot be higher than the number of images in the list (2).

Colors . Curves > HSV strange one, works once but second time gives this.
*** Error in ./fx_curves_interactive/*if/*local/ *** Command ‘input’: Invalid argument ‘(0,0,100,100,-1,0,0,58.4541054,34.2995(…)00,-1,0,0,100,100,-1,0,0,100,100,-1,)’.

*** Error in ./fx_simulate_grain/__fx_simulate_grain/+input_cached/ *** Command ‘done’: Not associated to a ‘repeat’, ‘for’ or ‘foreach’ command within the same scope.

Stopped here: I did not look in testing section

G’MIC 3.1.0 is clearly broken at the moment. I’m working hard to debug it right now, but I’d say it’s not really the moment to test it :slight_smile:

Have no fear, I always keep a backup :sweat_smile:

I think I now have something “good enough” for a pre-release.
Lot of commits and code change today, to make it work as expected.
I’ve also modified the gmic-community files to make them work with the future 3.1.0 version of G’MIC.

I’m currently building new pre-release binaries. Should be available in one hour or so!

I am not sure about done replacing endl. We would be asking, done what? But this exists in other languages (I think), so people have thought through the problem more than I have. PS - and done is being used elsewhere, so I guess it makes sense to make it more consistent.

Now, done is used to end any kind of iteration block or local environment. Definitely easier to remember :slight_smile: (except for do...while, as it must ends with a conditional expression).

I suppose we could add a comment after done to denote what it is for.

repeat ... done # my and my dog's laundry

Yes, usually in this kind of situations, correct indentation of the code also helps a lot.

Also, if 'done does not sound good to you, we could think about another keyword, while we are at it.
I think end would be too brutal anyway.

I don’t see a problem with using done for end of scope. After all, there are plenty other languages with only {...} for scope which works fine. The indentation/formatting should make it clear.

1 Like

BTW, I’m interested by your feedback on the changes.
There are probably quite a few bugs remaining, but really this took me further than expected.
I’ve basically re-checked and recoded a lot of code for flow control and exception handling.

Note that onfail now works inside foreach commands too.
I’ll probably won’t support it for other blocks, as it has a slight time overhead that it not welcome in more traditional loops (and as foreach needs to create a local environment for each loop iteration, this doesn’t affect it).

In that case, I’ll spend some time with it this weekend :slight_smile:

Edit: couldn’t resist a quick go - it makes doing loops at the terminal so much easier. This is absolutely worth the temporary pain!

1 Like

Actually, that may be something I could implement as well, } could be a shortcut for command done. That could be fun!

Basically the idea would be simply to :

  • Make { a shortcut for (no command) (as , is).
  • Make } a shortcut for done.

It could allow things like that (while keeping the compatibility with the existing syntax, of course.

foo : 
  foreach {
    +blur 10 -- n 0,255
    repeat 5 { sharpen 10 }
  }

What do you think ?

Well since I see this daily anyway it would be sugar for me :slight_smile:

Trying to think of downsides… any problems with shell stuff perhaps? The math parser uses them as well.

Actually, } could even be a shortcut for ‘end of current block’, whether it is a fi or done.
So:

foo : 
  if u<0.5 { echo[] "Yipeee!" }

would be valid too.

Edit: Probably harder to let } have different meanings, so I’ll stick with done at first.

Probably not suitable for being used on a shell, but more on a script file.
Shell users could still use the done keyword.

Yes, but it would be super-easy to detect { and } used as commands rather than math expressions, so not a big deal for the interpreter.

I think i’m gonna try to implement this, and see what happens :slight_smile:

1 Like