From: Nick Keighley on
On 8 May, 07:50, "io_x" <a...(a)b.c.invalid> wrote:
> "Lie Ryan" <lie.1...(a)gmail.com> ha scritto nel messaggionews:4be4b38f$1(a)dnews.tpgi.com.au...
> > On 05/08/10 10:39, Lie Ryan wrote:

> >> I've never heard of any programming languages that doesn't support
> >> recursion.
>
> > except for assembly, perhaps... or some very ancient or jokular languages
>
> with assembly is possible to write recursions functions too

depends on the architecture
From: Nick Keighley on
On 8 May, 11:25, "Nathan Baker" <nathancba...(a)gmail.com> wrote:
> "Juha Nieminen" <nos...(a)thanks.invalid> wrote in message
> news:4be50dcf$0$2544$7b1e8fa0(a)news.nbl.fi...
> > In comp.lang.c++ io_x <a...(a)b.c.invalid> wrote:

> >> with assembly is possible to write recursions functions too
>
> >  That's like saying that C supports object-oriented programming.
>
> Of course it does!  C certainly has support for data structures.
>
> There is absolutely no high-level language feature that can't also be
> implemented in C and ASM.

the Turing tar pit where everything is possible and nothing is
feasible



From: Keith Thompson on
Juha Nieminen <nospam(a)thanks.invalid> writes:
> In comp.lang.c++ io_x <a(a)b.c.invalid> wrote:
>> with assembly is possible to write recursions functions too
>
> That's like saying that C supports object-oriented programming.

Depending on the architecure, not really. Supporting full
object-orientation in C can be quite difficult. For some assembly
languages (certainly for the very few I've used), recursion is just
a matter of having a subroutine call itself.

--
Keith Thompson (The_Other_Keith) kst-u(a)mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
From: Nick on
Keith Thompson <kst-u(a)mib.org> writes:

> Juha Nieminen <nospam(a)thanks.invalid> writes:
>> In comp.lang.c++ io_x <a(a)b.c.invalid> wrote:
>>> with assembly is possible to write recursions functions too
>>
>> That's like saying that C supports object-oriented programming.
>
> Depending on the architecure, not really. Supporting full
> object-orientation in C can be quite difficult. For some assembly
> languages (certainly for the very few I've used), recursion is just
> a matter of having a subroutine call itself.

And, in all but the most trivial cases, using a couple of push/pop
instructions to keep some state between calls. It's certainly easier to
write recursive functions in assembly than in old "line number only and
no local variables" BASIC.
--
Online waterways route planner | http://canalplan.eu
Plan trips, see photos, check facilities | http://canalplan.org.uk
From: Richard Heathfield on
Juha Nieminen wrote:
> In comp.lang.c++ Richard Heathfield <rjh(a)see.sig.invalid> wrote:
>> Juha Nieminen wrote:
>>> In comp.lang.c++ Richard Heathfield <rjh(a)see.sig.invalid> wrote:
>>>> If the data are sorted, bsearch.
>>>>
>>>> If not, why not?
>>>>
>>>> In any case, your loop condition expressions do not correctly describe
>>>> the conditions under which the loop will terminate. Please rewrite your
>>>> example so that they do, and then by all means ask me again if you wish.
>>> No offense, but it always amuses me how some C programmers try to
>>> wiggle themselves out of actually giving honest answers when they are
>>> presented with problematic situations related to their coding style, C,
>>> or both.
>> Your paragraph, above, is a classic example.
>
> You know, an answer of "no, you are" is rather childish. How about
> presenting some actual arguments instead?

Well, I thought I had done so. Sorry for the late reply, by the way -
I've been kinda busy.

> I gave you a piece of code and asked you to modify it to conform to
> your principles. You did not do that. Who is trying to avoid answering
> to a challenge here?

Oh, I can modify it easily enough, and I am reasonably confident of how
you'll react to the modification, but here it is anyway. I am too
lazy/tired to look up your original code now, but IIRC basically you're
searching through an unsorted 3D array, which I would do along these lines:

/* p is a pointer to a valid "struct point" object, with x, y, and z
members */

int found = 0;
for(x = 0; !found && x < xlim; x++)
{
for(y = 0; !found && y < ylim; y++)
{
for(z = 0; !found && z < zlim; z++)
{
if(haystack[x][y][z] == needle)
{
found = 1;
point_assign(p, x, y, z); /* that is, p.x = x; p.y = y, etc */
}
}
}
}
return found;

And I know you're not going to like the extra tests any more than I like
your early returns. Style issue.

<snip>

>>> Is it *really* that hard to simply say "yes, in this particular example
>>> the 'return' is indeed the simplest way"? Does it hurt your pride or
>>> something?
>> What has pride got to do with it? It's common sense, that's all. The
>> simplest way (and one of the fastest) to get from Tower Bridge Approach
>> to St Katharine's Way is to jump off the bridge, but that doesn't
>> necessarily mean it's the /best/ way.
>
> Then kindly show me this "best way".

One man's best is another man's mediocre, and a third man's worst. <shrug>

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
"Usenet is a strange place" - dmr 29 July 1999
Sig line vacant - apply within