Richard Hainsworth wrote:
<snip>
I don't know why, this given... when sounds so 'English' without
really being that
English.
The construct <given ... when> sounds better in English than <switch
... case ...> because:
a) Switch is more commonly used in English as a noun, eg., Use the
switch to turn on the light. But because English can use nouns for
verbs and adjectives as well, eg., 'Switch on the light' or 'he is a
switched-on type of guy', it seems ok to use it in for control
purposes. Except ... the verb is really 'switch on' not 'switch'. Also
we have 'switch over', 'switch from', 'switch between' etc. where as
'switch' as a verb as in 'she just switched boyfriends' means
exchanging one for another, not choosing between alternative cases. So
really 'switch' as a verb is really more like 'toggle'. So when an
English person (or at least one that cares about the use of language)
sees 'switch' in a programming language, there is the feeling that
something is missing, or not quite right. And there is absolutely no
linguistic link between 'switch' and 'case'. If I am uncomfortable
with 'switch', 'case' really sucks. In fact, whenever I work in
language other than perl, and 'switch' is the preferred construct, I
always have to check the syntax to work out what goes where.
b) 'Given' is more commonly used in English as a verb form. 'He was
given an award'. Also, it is in the correct form for use at the
beginning of a sentence, eg., 'Given three choices, he chose the most
profitable'. So we have something that looks and feels like it is a
part of normal English speech. The 'when' part is also a natural tag
in English indicating one of several alternatives. 'Given' can be used
as noun (the power of English! as a language) as in 'we have a number
of givens, but the issue is still unresolved'. This is much rarer than
the use of 'given' in verb uses.
c) You might ask, why bother? Just choose words, and since switch is
the most common one, just use it. Well, computers dont care whether
you use words or symbols, so long as semantics can be uniquely
extracted from syntax, that is, the computer knows uniquely what you
are trying to say to it. But the reality is that humans dont work that
way. From the time of FORTRAN and COBOL, the aim has been to choose
words over symbols so that they have semantic meaning for the
programmer. It makes it easier for programmers to write descriptions
of algorithms and operations, and to understand the logic of the
descriptions they are writing. This reduces development and debugging
time. Perl has been so successful, and my programming language of
choice, because where words have been chosen, they have very similar
semantics to normal English. That helps me in my programming.
I've never said that switch ... case was better than given ... when
or that switch ... case was even a good construct.
I have said that given ... when sounds weird as a construct
(not mentionning the use of past participle and on top of that of an
irregular verb).
I understand the meaning and I can get over it
but is proliferation of English idioms, words a good idea?
There're bunch of words that could describe the same idea
in a sligtly different manner.
Perhaps writting a la smallTalk could be the solution.
getting rid off all shortcuts and change them into explicit description
entities and write english sentences, not programs.
This could be nice but I will first have to learn English.
Anyway, I will write my own 'Lingua::Given::Francais' with avec ...
lorsque^^:
(well, if I can - ^^; xx 1000 )
--
シリル・デュモン(Cyrille Dumont)
[EMAIL PROTECTED]
our work is the portrait of ourselves
tel: 03-5690-0230 fax: 03-5690-7366
http://www.comquest.co.jp