[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Format
- From: Markus Huber <pulse@...>
- Date: Thu, 12 Apr 2001 17:05:45 +0200 (BST)
> Jean-Claude Wippler:
> > Markus Huber:
> > Python... I think the syntax system is stupid, because I like
> > to format it readable:
> >
> > print (" Function ",Function )
> > if Delimiter then print (" Delimiter ",Delimiter ) end
> > print (" String ",String )
> > print ("Expression ",Expression)
> Are you dismissing a language on the basis of visual preferences?
*No* I would like only the freedom to do things in my format/style.
Following 'ARM BBC BASIC V version 1.16 (C) Acorn 1989' excerpts to show
my style in detail:
CASE INSTR(`Metacharacters$,`ExpressionChar$) OF
WHEN 0 :REM Isn't a metacharacter
`NextChar$+= `ExpressionChar$
`NextChar% = NOT `CollectChar%
WHEN 1 :REM |
`NextChar$ = ""
`NextChar% = TRUE
WHEN 2 :REM ~
`ExpressionFallbackTilde% = `ExpressionPosition%
`ExpressionFallback% = `ExpressionPosition%
`Search% = TRUE
`InternalDelimiter$ = ""
WHEN 3 :REM *
`ExpressionFallback% = `ExpressionPosition%
`Search% = TRUE
`InternalDelimiter$ = `Delimiter$
IF String_FromPosition% =-1 THEN
String_FromPosition% = `StringPosition%-(`String$>"")
ENDIF
WHEN 4 :REM ?
`NextInvert% = TRUE
`NextChar$ = `Delimiter$
`NextChar% = TRUE
WHEN 5 :REM #
`NextChar$+= "0123456789"
`NextChar% = NOT `CollectChar%
WHEN 6 :REM \
`ExpressionPosition%+=1
`NextChar$+= MID$(`InternalExpression$,
`ExpressionPosition%,1)
`NextChar% = NOT `CollectChar%
WHEN 7 :REM [
`CollectChar% = TRUE
WHEN 8 :REM ]
`CollectChar% = FALSE
`NextChar% = (`NextChar$>"")
WHEN 9 :REM !
IF `CollectChar% THEN
`NextInvert% = TRUE
ELSE
`NextChar$+= `ExpressionChar$
`NextChar% = NOT `CollectChar%
ENDIF
ENDCASE
Ok I shouldn't do that type of program in basic - please forgive. The $
and % are type definitions. The ` is my way to declare this variable as
an library local related. I like upper case commands for a better
readability without syntax coloring. But I use always syntax coloring.
I use simple but strict rules for variable *and function* names:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
First of all: the chars ` and _ are reserved to declare the scope.
<Libraryname has to be 4 or more characters long>
-------------------------------------------------
<Libraryname>_<Variablename> - global in library; also external use
<Libraryname>`<Variablename> - global in library; only internal use
`<Variablename> - local in library; only used in one function
_<Variablename> - local in library; but also for subfunctions
so its a mix between a local and a global type
usefull for recursive subfunctions
<Groupname has to be 3 or less characters long>
-----------------------------------------------
Main_<Variablename> - global in program
<Groupname>_<Variablename> - global in main program
e.g. Cnf_ for configuration
<Variablename> - local in main program
I use this system to know always the scope of any variable. Object
orientation can't solve this in 100%. So I use this for procedural as
for object orientated programming too.
Next point I don't like: most languages are using only '}', Lua use
'end', 'until'. But I like the difference between ENDIF, ENDWHILE, NEXT,
and UNTIL. Look at this:
Do something
}
}
Loop+=1
}
}
You can't say if it is the right order or not. Ok - normaly
blocks/functions should not longer as ~ 50 lines but not seldom it is
very better to do longer things in one chunk. In the following example
you see without knowing the header whats going on:
Do something
ENDIF
ENDIF
Loop+=1
ENDWHILE
NEXT
Also I use upper and lower case for Variables:
File_CompareDate
File_GetFiletype
File_EnsurePath
File_EvaluatePath
GetFiletype or GetFileType? Not more difficult as
get_file_type or get_filetype but less chars.
Sorry for driffting away. Conclusion: I would like only the freedom to
do things in my format/style - so we come back to Lua. Lowercase
commands only and no endwhile... is acceptable.
>> PHP... the other side of a language x-thousand commands
>> Perl... to cryptic
>> Ruby... ? never used
>> Pike... more like C I think
>> tcl... ? never used
> Tcl/Tk is not "in". I have no idea why. I use it quite a bit.
Michael T. Richter: "I stopped using Tcl/Tk when I first got burned by
the "comments can impact code" problem."
I would like to use any type of comments ;-)
Markus