[Geany-devel] Default snippets

Alexander Eberspächer alex.eberspaecher at xxxxx
Fri Aug 26 12:49:06 UTC 2011


Hey Lex, hello list,

On Fri, 26 Aug 2011 22:04:01 +1000
Lex Trotman <elextr at gmail.com> wrote:

> > The snippets for the loops assume that the counting variable is
> > shall be i.  
> Thats traditional...

But still making a rather strong  assumptions about what the user wants.

> For C++ its fine to re-declare i within the loop, it will hide any
> external declaration.

Okay, didn't remember that. Is that true for C# and Java also?

> > seems to work for most people, however, I personally would opt for
> > completion of
> >
> > "do"
> >
> > to
> >
> > "for (%cursor%)
> > {
> >
> > }"
> >
> 
> Thats a bit counter-intuitive since there is a do statement, and it is
> post tested rather than pre-tested like for. Maybe use something else
> for for two (pun intended :) or change the original

Of course I meant "for" to be completed - I was creating to patch while
I wrote some Fortran code, and in Fortran C's 'for' is basically
'do' :/ Sorry for the confusion.

> In C++ it is more common than in C to use other loop operations (eg
> iterators) not just simple counters, so maybe the blank version would
> be better as the main for entry for C++.

Any other opinions on that? Your suggestions breaks consistency with
C/C#/PHP...

> Maybe you should preserve default behavior on the basis that someone
> decided it to be that way, unless you know no one cares.

I want to make my point about assumptions a bit clearer: if a user
writes 'for' in C program and hits the completion key, one can be sure
that this user wants a for loop. However, you cannot (and IMHO, to keep
snippets useful for any user, must not) be sure that the user wants 'i'
to be the counting variable.

So, what do other people think? The patch should not break what people
actually use. However, a *consistent* set of snippets uses either a
default counting variable for all languages or doesn't fill in any at
all.

> I dunno, all the sigmas I remember used i & j, and in original fortran
> all variables starting with i to n were integers, so again tradition
> has it to use i,j,k,l,m,n.

That's Fortran 77. From Fortran 90 on, there is the 'implicit none'
statement that tells the compiler not to use implied types. I've already
added a snippet for that. 

> PS You seem to have got a copy of the for entry tacked on to the end
> of the switch snippet for C++ & C#

Oops. Fixed (patch attached).

> PPS there seem to be line breaks in some entries, (eg switch)  entries
> must be on one line

Can't see any line breaks.

So I hope there will be some discussion on what the default snippets
should do. I am happy to create a patch that does just whatever the
discussion results in.

Cheers

Alex
-------------- next part --------------
A non-text attachment was scrubbed...
Name: default_snippets.patch
Type: text/x-patch
Size: 4566 bytes
Desc: not available
URL: <http://lists.geany.org/pipermail/devel/attachments/20110826/a586af1c/attachment.bin>


More information about the Devel mailing list