On 15.03.2010 22:49, nullPointer wrote:
Well, perhaps is a theme worked in another times but... is possible for Pharo
have a basic Case or elseIf statement? I know is easy create you own
structure control, but not is more useful have a "standard" for everybody?
I´m tired of write code like that...
(self currentRow == sortedRows last and: [ self
currentCell isNil ]) ifTrue:
[
self navigationKey: event
]
ifFalse:
[
(self currentRow notNil and: [ self currentCell
isNil ]) ifTrue:
[
self setCurrentRowToNext.
]
ifFalse:
[
(self currentRow notNil and: [ self
currentCell notNil ]) ifTrue:
[
self setCurrentCellToNext.
self currentCell notNil ifTrue:
[
self currentCell
performKeyFocus: event inCellBounds: (self
pvtGetCellBounds: self currentCell).
].
].
].
].
Write code with that format is pathetical :(
Is valid too have a "and" and "or" lazy? Exists a not lazy with #& and #| ,
but could exists an #&& and #|| . Is more easy...
value1 == value2 and:[<condition> ] and: [<condition>] ......
or
value1 == value2&& <condition> && <condition> ......... ???
Well, perhaps is a stupid question but I miss a more complete way for write
code. If in Smalltalk is possible do easy that and include it in "core" why
not do it?
Is a reasonable desire :)
Regards
It's a lot clearer what the code does when you avoid repeating checks in deeper
nested levels.
Why not rewrite to the equivalent expression:
self currentCell
ifNil: [
self currentRow == sortedRows last
ifTrue: [self navigationKey: event ]
ifFalse: [self currentRow ifNotNil: [self setCurrentRowToNext]]
ifNotNil: [
self currentRow ifNotNil: [
self setCurrentCellToNext.
self currentCell performKeyFocus: event
inCellBounds: (self pvtGetCellBounds: self
currentCell)]]
if sortedRows last cannot be nil, you could even write:
self currentRow ifNil: [^self].
self currentCell
ifNotNil: [
self setCurrentCellToNext.
self currentCell performKeyFocus: event
inCellBounds: (self pvtGetCellBounds: self currentCell)]
ifNil: [
self currentRow == sortedRows last
ifTrue: [self navigationKey: event]
ifFalse: [self setCurrentRowToNext]]
Cheers,
Henry
_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project