|First language with conditional assignment? firstname.lastname@example.org (2011-03-03)|
|Re: First language with conditional assignment? email@example.com (Nils M Holm) (2011-03-04)|
|Re: First language with conditional assignment? firstname.lastname@example.org (glen herrmannsfeldt) (2011-03-04)|
|Re: First language with conditional assignment? email@example.com (BGB) (2011-03-04)|
|Re: First language with conditional assignment? firstname.lastname@example.org (2011-03-05)|
|Re: First language with conditional assignment? email@example.com (robin) (2011-03-05)|
|Re: First language with conditional assignment? firstname.lastname@example.org (Andy Walker) (2011-03-05)|
|Re: First language with conditional assignment? email@example.com (Stefan Monnier) (2011-03-05)|
|Re: First language with conditional assignment? firstname.lastname@example.org (Derek) (2011-03-06)|
|Re: First language with conditional assignment? email@example.com (2011-03-07)|
|[8 later articles]|
|Date:||Fri, 04 Mar 2011 14:54:21 -0700|
|Keywords:||history, syntax, comment|
|Posted-Date:||04 Mar 2011 23:56:19 EST|
On 3/4/2011 9:00 AM, Nils M Holm wrote:
> firstname.lastname@example.org wrote:
>> Does anyone know what the earliest languages supporting conditional
>> assignment were? Although the construct is useful I don't like the syntax in
>> C-like languages. I am curious if there were earlier examples and what the
>> syntax was.
I understood it to mean more like:
but, for that, I am not sure of much of anything that could be much
nicer syntax-wise, or for that matter, much more efficient.
> In case you meant conditional expressions like C's
> predicate? consequent: alternative
> then BCPL had
> predicate-> consequent: alternative
> in 1966 and and LISP had
> (COND (predicate1 expression1) ...)
> in 1960.
in some of my languages, I have also had:
if(predicate) left_expr else right_expr
but, this is semantically equivalent to:
either way seems good enough...
sometimes, I have wished for C to have a good sort of "switch that
returns a value" block.
case "a": break("Foo-A");
case "b": break("Foo-B");
well, this along with switch accepting non-integer values.
in in-development language ("BGBScript2") does have the ability to
switch on strings and a few other types (although, they have to be able
to be evaluated to compile-time constants and also be comparable, and
all case expressions are limited to being the same type).
however, I have not spec'ed out such a value-returning switch yet, and
am largely hesitating on defining too many features until at least a
basic form of the language is fully implemented.
technically, switch is likely to be handled via binary dispatch, as my
compiler-related stuff (still) doesn't currently support jump-tables
(and jump-tables will only really work with integers anyways).
but, at least, binary dispatch is still faster (in non-trivial cases)
than a long if/else chain...
[If you want a switch that returns a value, take a look at BLISS. -John]
Return to the
Search the comp.compilers archives again.