Related articles |
---|
First language with conditional assignment? compilers@is-not-my.name (2011-03-03) |
Re: First language with conditional assignment? nmh@t3x.org (Nils M Holm) (2011-03-04) |
Re: First language with conditional assignment? gah@ugcs.caltech.edu (glen herrmannsfeldt) (2011-03-04) |
Re: First language with conditional assignment? cr88192@hotmail.com (BGB) (2011-03-04) |
Re: First language with conditional assignment? kym@kymhorsell.com (2011-03-05) |
Re: First language with conditional assignment? robin51@dodo.com.au (robin) (2011-03-05) |
Re: First language with conditional assignment? news@cuboid.co.uk (Andy Walker) (2011-03-05) |
Re: First language with conditional assignment? monnier@iro.umontreal.ca (Stefan Monnier) (2011-03-05) |
Re: First language with conditional assignment? derekrss@yahoo.ca (Derek) (2011-03-06) |
Re: First language with conditional assignment? compilers@is-not-my.name (2011-03-07) |
[8 later articles] |
From: | BGB <cr88192@hotmail.com> |
Newsgroups: | comp.compilers |
Date: | Fri, 04 Mar 2011 14:54:21 -0700 |
Organization: | albasani.net |
References: | 11-03-006 11-03-008 |
Keywords: | history, syntax, comment |
Posted-Date: | 04 Mar 2011 23:56:19 EST |
On 3/4/2011 9:00 AM, Nils M Holm wrote:
> compilers@is-not-my.name 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:
if(x<y)x=y;
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:
predicate?left_expr:right_expr
either way seems good enough...
sometimes, I have wished for C to have a good sort of "switch that
returns a value" block.
like:
foo=switch(x)
{
case "a": break("Foo-A");
case "b": break("Foo-B");
...
default: break("Unknown");
};
but, alas...
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.
note:
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
comp.compilers page.
Search the
comp.compilers archives again.