From: io_x on

"io_x" <a(a)b.c.invalid> ha scritto nel messaggio
news:4bdda3e7$0$1112$4fafbaef(a)reader4.news.tin.it...
> "Red Rooster" ha scritto nel messaggio
> I advise them it could be not always so,
> there could be one language in wicht goto is easy :)

for example in these days i wrote this function for one sub-window
that gets data

90% of lines has at last one goto, #, jc, jmp etc
i'm naturally sloppy, doing some math count with my fingers
i'm not much smart, not remember [nor want remember] somting like many OS api

how is possible that both this routine and its sub-windows goes well?
it call the server, send data, and set the right answer

; void DialogButtonClick(u32 Handle, u32 Message)
; 0j, 4i, 8Ra, 12Handle, 16Message
; 2048, 2052, 2056, 2060, 2064
; 0k,4j,8i,12b,16Ra, 20P_Handle, 24P_Message +2048
; 2068 2072
align 4
DialogButtonClickCliente:
<b,i,j,k
<< NConto=160
s-=2048
; iint3
i=^2068|a=^2072|#.1
..e: a=0| stc| ##.z
..1: a==ID_DC_BTN_INVIA!#.8
a=s|D*s=0|SetDlgItemTextA(i, ID_DC_ED_RISULTATO, a)
; iint3
DC_VerificaCampi(i)|jnc .1a
..1e: DC_StampaErrore(i,a)|#.9 ; caso errore non sanabile
; controlli dopo questo punto
; tipo "GetDlgItemTextA(,,)|a<=0?#.9"
; dovrebbero essere inutili poiche' sono
; stati fatti in DC_VerificaCampi(i)
..1a: a==2!#.2 ; n conto inesistente => cerca dal nome e cognome n conto
a=NomeDaInviare |GetDlgItemTextA(i, ID_DC_ED_NOME1, a,
32)|a<=0?#.9
a=NomeDaInviare |IsSpaceString_m(a)|a==1#.9
a=CognomeDaInviare|GetDlgItemTextA(i, ID_DC_ED_COGNOME1, a,
32)|a<=0?#.9
a=CognomeDaInviare|IsSpaceString_m(a)|a==1#.9
k=NomeDaInviare |j=CercaNumeroDalNomeCognome
; Quando si preme il tasto invia
; se esiste un tread [risposta attesa] => segnala errore [esiste
gia' operazione]
; altrimenti
; apre un thread con il compito di aggiornare tutti i campi
; di cui ID_MD_ED_RISULTATO e' quello che il tread puo'
scrivere
; insieme a ID_MD_ED_NCONTO
..1aa: D*trhandle#.1c ; in trhandle il solo thread apribile
..1b: a=&^64|*a=i|*a+4=k|D*a+8=0|r=&^16 ; D*a+8==1 finestra
principale
; D*a+8==0 finestra cliente
CreateThread(0, 0, j, a, 0, r)|a==0#.1e
*trhandle=a|#.9
..1c: a=*trhandle|c=s|GetExitCodeThread(a, c)|a==0#.1e
a^=a
D*s!=&STILL_ACTIVE!#.1e ; se il processo e' terminato
a=*trhandle|CloseHandle(a)|a==0#.1e|D*trhandle=0|#.1b
#.9
..2: a==3!#.3 ; n conto presente ma assenti nome e cognome =>
; cerca nome e cognome dal numero di conto
a=&*s+NConto|GetDlgItemTextA(i, ID_DC_ED_NCONTO, a, 32)|a<=0?#.9
k=&*s+NConto|j=DC_CercaDalContoCliente|#.1aa
#.9
..3: a#.9 ; a==0 significa estono il numero conto e anche i nomi e cognomi
a=&^24|CB_GetText(a, 40, i, ID_DC_CMB_OPERAZIONI)|jc .9
c==0!#.4 ; inserisci nuovo cliente
k=0 ; k not used
j=DC_InserisciCliente|#.1aa
#.9
..4: c==1!#.5 ; elimina cliente
k=0 ; k not used
j=DC_EliminaCliente|#.1aa
#.9
..5: ; variazione dei dati cliente
#.9
..8: a==ID_DC_BTN_AZZERA!#.9
azzeraFormCliente(i)
..9: a=1|clc
..z:
s=&*s+2048
>> NConto
>b,i,j,k
ret 8


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
From: Nick Keighley on
On 8 May, 17:46, Tim Streater <timstrea...(a)waitrose.com> wrote:
> In article
> <5dd9bdc8-4dc4-4537-84a0-885c4c92f...(a)l28g2000yqd.googlegroups.com>,
>  Nick Keighley <nick_keighley_nos...(a)hotmail.com> wrote:
> > On 8 May, 01:41, Lie Ryan <lie.1...(a)gmail.com> wrote:


> > > > I've never heard of any programming languages that doesn't support
> > > > recursion.
[...]
> > FORTRAN (in its original form), Coral-66 you had to use a special
> > keyword to indicate a function was recursive. Some BASICs probably
> > didn't alow recursion. But these all qualify as "ancient" (and maybe
> > jocular!)
>
> What FORTRAN are you referring to. I never saw it in any FORTRAN up to
> 1978 (the last time I used FORTRAN).

lost me. So far as I remember FORTRAN didn't have recursion. Am I
wrong? Or are you saying even modern Fortran doesn't have recursion?
From: Sjouke Burry on
Nick Keighley wrote:
> On 8 May, 17:46, Tim Streater <timstrea...(a)waitrose.com> wrote:
>> In article
>> <5dd9bdc8-4dc4-4537-84a0-885c4c92f...(a)l28g2000yqd.googlegroups.com>,
>> Nick Keighley <nick_keighley_nos...(a)hotmail.com> wrote:
>>> On 8 May, 01:41, Lie Ryan <lie.1...(a)gmail.com> wrote:
>
>
>>>>> I've never heard of any programming languages that doesn't support
>>>>> recursion.
> [...]
>>> FORTRAN (in its original form), Coral-66 you had to use a special
>>> keyword to indicate a function was recursive. Some BASICs probably
>>> didn't alow recursion. But these all qualify as "ancient" (and maybe
>>> jocular!)
>> What FORTRAN are you referring to. I never saw it in any FORTRAN up to
>> 1978 (the last time I used FORTRAN).
>
> lost me. So far as I remember FORTRAN didn't have recursion. Am I
> wrong? Or are you saying even modern Fortran doesn't have recursion?

If recursion does not exist, I will have to ditch quite a couple
of fortran programs.
There is only 1 hitch, you have to write a 3 line dummy routine,
to do the calling, so a calls b , b calls a.
fortran MS 5.1 and later.
Also Fortran77 for Riscos (arc 320 computer)