Another spinoza challenge

D

David Thompson

On Tue, 25 Aug 2009 07:34:53 -0700 (PDT), Nick Keighley
Consider
success_t search (int *index, Dictionary *dict, Value val);

I'd quite happily say "A Dictionary is passed to the search function,
if the
search suceeds the function returns true and also returns the index
of the value found".
First, I'd make that const Dictionary *. I might say 'also returns
the index' but alternatively I might say 'stores' or 'sets'.
See no pointers or references

I quite like Ada's in, out and inout parameters. Though in practice I
don't use the terms. I suppose I still think in a Pascal-like way
and just treat C's pointers and The Rule as its slightly excentric
of providing me with what I want.
(SpellNit: eccentric.)

Pascal VAR/non specifies mechanism. Ada in/out/inout may influence it,
but does not require it. Some _types_ do: elementary types must be
by-value (called by-copy), tagged (aka polymorphic or dispatching)
types and a few others must be by-reference, and the rest are up to
the implementation's choice. 'in' may improve the chances of the
implementation choosing by-value, but doesn't require it.

Fortran90 adds INTENT IN/OUT/INOUT, which similarly does not control
but may influence mechanism. F03 adds VALUE which forces by-value
in limited cases; this was motivated mostly by C-interop, but can be
used otherwise. F90 'target' rules effectively require by-reference in
limited cases, and for any type you can have an explicit IN POINTER
(implicitly derefed in callee, but explicitly enabled in caller) and
in F03 you can use a C-interop pointer by value (explicit both sides).
I've never found
swap (&a, &b);

either natural or elegant. I *might* say a and b were passed by
reference.

I want to pass an array so I use array notation
double sum (double vector[], size_t size);

even though some people would say it confuses things to
hide the pointer
I like to use array notation when it is (at least usually) multiple
elements vs. pointer notation when it's only one (or maybe none).
But this is only my convention; the compiler doesn't check it.
In C99 I could use double sum ( size_t n, double v [n] )
but I'm in the C99-isn't-sufficiently-available-yet camp.
 
K

Keith Thompson

David Thompson said:
]
I quite like Ada's in, out and inout parameters. Though in practice I
don't use the terms. I suppose I still think in a Pascal-like way
and just treat C's pointers and The Rule as its slightly excentric
of providing me with what I want.
(SpellNit: eccentric.)

Pascal VAR/non specifies mechanism. Ada in/out/inout may influence it,
but does not require it. Some _types_ do: elementary types must be
by-value (called by-copy), tagged (aka polymorphic or dispatching)
types and a few others must be by-reference, and the rest are up to
the implementation's choice. 'in' may improve the chances of the
implementation choosing by-value, but doesn't require it.

Note that Ada requires elementary types to be passed by copy for all
three modes: in, out, and in out. For out and in out modes, the
values are copied back to the caller when the procedure returns. C
has no direct equivalent to this, though you could simulate it like
this:

void func(int *param /* in out by copy */)
{
int local_copy = *param;
/* operator on local_copy */
*param = local_copy;
}

[...]
 
D

Dik T. Winter

>
> Spinoza wasn't a slob.

To quote an earlier posting by you:
> Any slob in the 17th century, like Spinoza
so Spinoza now is not "any slob in the 17th century"? When did you
change opinion?
>
> From the point of view of the consumer, nothing else matters. But I
> didn't know that Holland has a lottery, nor did I know that you won
> it.

What is the relevance? Weather forecasts have become much more precise
over the last 30 years.
>
> Did you have a look at the code?

I knew the code, yes, thank you. It was a standard program that had been
written at our institute.
>
> I knew what the problem was. It sounds like you had a different
> problem in Yourup, where commas are sometimes periods.

Nope, there was indeed an error somewhere where somebody had typed a period
rather than a comma.
> Some compilers
> allowed the end and step values to be eliminated meaning that DO10I=3
> was ambiguous.

According to the standard it is simply an assignment. That some compilers
made errors is not new. Like the compiler where every line that started
with FORMAT( and linenumber in front was considered a format statement.
 
D

Dik T. Winter

>
> Not exactly a tour d'horizon, is it? More like a view from the
> trenches.

Perhaps, so what?
> And what has happened BTW to CDC?

Given up like so many others.
> Today, those universities no longer use Algol, do they?

I wouldn't think so. For one thing it is a bad language to get *fast*
compiled code in. Mostly they use now a plethora of languages.
 
P

Phil Carmody

Dik T. Winter said:
To quote an earlier posting by you:

Quote whole sentences when arguing semantics.
so Spinoza now is not "any slob in the 17th century"?

C, like any language with counted-strings, can cache the length of the string.

Phil
 
D

Dik T. Winter

>
> Because it is an itinerant troll. For ****'s sake, Dik, you are not
> normally stupid enough to fall for this kind of game.

No, I do not think he is trolling. At least not after I read his
pathetic "readers comment" about his own book on amazon.com. There
is a bit more to it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,111
Latest member
KetoBurn
Top