gm2
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Procedure Const parameter?


From: john o goyo
Subject: Re: Procedure Const parameter?
Date: Tue, 24 Mar 2020 15:00:18 -0400
User-agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.5; en-GB; rv:1.9.2.23) Gecko/20110920 Thunderbird/3.1.15

Hung Hung,

I concur with the suggestion from Andreas.  (Copies may found online.)

I have been a professional programmer for over 35y (mostly in procedural languages, such as C, but also others). When my job required learning a new language, I found it most useful to first work through the definitive book on the language. I never found it useful to try to translate code from another language first. Every language has its own philosophy and idioms. I strongly suggest immersion first. It may seem time-consuming but it pays well at a later stage.

Sincerely,
john

On 24/03/2020 14:29, Fischlin Andreas wrote:
Dear Hung Hung,

Given the many questions you ask, I highly recommend to you to read

Programing in Modula-2 by Niklaus Wirth. Springer. I recommend ed. 3.

This is anyway a very good and enjoyable read and should help you to understand 
M2 quickly, answer all your questions efficiently, and even introduce you to 
the spirit of Modula-2 and the structured programing it supports.

Regards, Andreas

ETH Zurich, Prof. em. Dr. Andreas Fischlin, IPCC Vice-Chair WGII, Systems 
Ecology, CHN E 24, Universitaetstrasse 16, CH-8092 Zurich, SWITZERLAND
Tel: +41 44 633-6090   Mobile: +41 79 595-4050   Mail: address@hidden
www.sysecol.ethz.ch/people/andreas.fischlin.html

On 24 Mar 2020, at 19:15, Gaius Mulley<address@hidden>  wrote:

Hưng Hưng<address@hidden>  writes:

Free Pascal has this: procedure test(const x: pchar);

What is the equivalent in gm2?

I want a const pointer. e.g:

type test = pointer to integer;
procedure testit(const x: test);

I need it to be able to complete the translation of the C header to
gm2.
Hi,

there is no const pointer in Modula-2

you can either use:

example.def

DEFINITION MODULE FOR "C" example ;

TYPE
   ptr = POINTER TO INTEGER ;

PROCEDURE foo (a: ptr) ;
PROCEDURE bar (VAR a: ptr) ;

END example.

fortunately you can either state this as const or without const in your
C file

example.c

void example_foo (const int *a);    /* add/remove const as suits.  */
void example_foo (int **a);    /* add/remove const as suits.  */

etc

regards,
Gaius





reply via email to

[Prev in Thread] Current Thread [Next in Thread]