From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 109fba,baaf5f793d03d420 X-Google-Attributes: gid109fba,public X-Google-Thread: fc89c,97188312486d4578 X-Google-Attributes: gidfc89c,public X-Google-Thread: 1014db,6154de2e240de72a X-Google-Attributes: gid1014db,public X-Google-Thread: 10db24,4cf070091283b555 X-Google-Attributes: gid10db24,public X-Google-Thread: 103376,97188312486d4578 X-Google-Attributes: gid103376,public From: mdw@excessus.demon.co.uk (Mark Wooding) Subject: Re: What's the best language to learn? [was Re: Should I learn C or Pascal?] Date: 1996/08/22 Message-ID: #1/1 X-Deja-AN: 175840633 x-nntp-posting-host: excessus.demon.co.uk references: <4v26j4$hkg@news.csus.edu> <01bb8d2f$351b9500$32ee6fce@timhome2> <4vdon9$8nt@news1.mnsinc.com> organization: Straylight Development Lab reply-to: mdw@excessus.demon.co.uk newsgroups: comp.edu,comp.lang.ada,comp.lang.c,comp.lang.c++,comp.unix.programmer Date: 1996-08-22T00:00:00+00:00 List-Id: Szu-Wen Huang wrote: > Lofty, ungraspable concepts like: > > void swap(int *a, int *b) > { > int c = *a; > > *b = *a; > *a = c; > } > ... > swap(&a, &b); > ... > > ? swap(), by the way, is a primitive for just about every algorithms > text I've ever read. Does knowing the computer must: > > LOAD r1, a > ADD something_else_totally_unrelated > LOAD r2, b > INC some_counter_from_another_place > STOR r1, b > INC that_same_counter_but_we_just_need_to_fill_the_slot > STOR r2, a > > in order to swap two integers aid in the understanding of swap()? > I agree that we need to break an algorithm down to primitives, but > are you actually saying swap(), for instance, isn't primitive enough? I think you're deliberately trying to choose a nasty architecture. We're talking about teaching, I think, so why not choose an easy one? ; --- swap --- ; ; Just like void swap(int *a,int *b) swap LDR a3,[a1] LDR a4,[a2] STR a3,[a2] STR a4,[a1] MOV pc,lr Simple. (And now there's a 200MHz version of this processor, so it's not /that/ old-fashioned.) -- [mdw] `When our backs are against the wall, we shall turn and fight.' -- John Major