Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2013-06

Declaration of arrays

12 messages · 7 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Rainer Stratmann

For some days I have the mikroPascal Compiler from Mikroelektronika. And I am satisfied with it.

http://www.mikroe.com/mikropascal/avr

With that product the declaration of an array is also possible with only one number.

For example:

var test : array[ 10 ] of byte;

Like in C.
That would make migration from C to Pascal easier.

Is it posssible to integrate this in Freepascal also?

Reply by email

leledumbo
to Rainer Stratmann

I think this was requested a looooooooong time ago but was rejected. I forgot what was the reason, but I myself don't really like it despite it's upward compatible with Oberon. As for easy migration from C, do you really think removing "0 .." (approximately 4 characters) is a benefit?

View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Declaration-of-arrays-tp5715345p5715365.html Sent from the Free Pascal - General mailing list .

Reply by email

Alberto Narduzzi
to leledumbo

On 18/06/13 18:42, leledumbo wrote:

well, to be honest, int hahaha[10] -> hahaha: array[0..9] of integer;

it is not just adding "0.."

anyway, a change in the converter should be more adequate, IMHO, that by default translates [X] into [0 .. X-1]

just my 2c

I think this was requested a looooooooong time ago but was rejected. I forgot what was the reason, but I myself don't really like it despite it's upward compatible with Oberon. As for easy migration from C, do you really think removing "0 .." (approximately 4 characters) is a benefit?

Reply by email

Rainer Stratmann
to Alberto Narduzzi
As for easy migration from C, do you really think removing "0 .." (approximately 4 characters) is a benefit?

Yes of course. In large programs it is helping you to be correct all the time when migrating code. See also the statement of Alberto.

anyway, a change in the converter should be more adequate, IMHO, that by default translates [X] into [0 .. X-1]

In C(++) arrays are defined only like you describe. Freepascal can easily adapt this, I am sure.

Reply by email

Florian Klämpfl
to Rainer Stratmann
Rainer Stratmann wrote 5 lines
> As for easy migration from C, do you really > think removing "0 .." (approximately 4 characters) is a benefit? Yes of course. In large programs it is helping you to be correct all the time when migrating code. See also the statement of Alberto.

You can use the argument of Alberto in a different sense: migration is easier but people might make mistakes when reading the code.

Reply by email

Rainer Stratmann
to Florian Klämpfl
you wrote 9 lines
Am 18.06.2013 22:02, schrieb Rainer Stratmann: >> As for easy migration from C, do you really >> think removing "0 .." (approximately 4 characters) is a benefit? > > Yes of course. In large programs it is helping you to be correct all the > time when migrating code. See also the statement of Alberto. You can use the argument of Alberto in a different sense: migration is easier but people might make mistakes when reading the code.

Yes that is with all kind of information if you don't have backgrund knowledge. But in this case there aren't much possibilities of misunderstanding the code. And it is not that difficult to understand than for example some kind of object oriented programming.

As reading your statement between the lines I think you would like to refuse the suggestion, right?

Reply by email

Jonas Maebe
to Rainer Stratmann
Rainer Stratmann wrote
Yes that is with all kind of information if you don't have backgrund knowledge.

Minimising the amount of required background knowledge and making everything self-explanatory is a fundamental part of the Pascal philosophy.

As reading your statement between the lines I think you would like to refuse the suggestion, right?

Adding redundancy to a language is seldom a good idea.

Jonas

Reply by email

Rainer Stratmann
to Jonas Maebe
you wrote 13 lines
On 18 Jun 2013, at 22:22, Rainer Stratmann wrote: > Yes that is with all kind of information if you don't have backgrund > knowledge. Minimising the amount of required background knowledge and making everything self-explanatory is a fundamental part of the Pascal philosophy. > As reading your statement between the lines I think you would like to > refuse the suggestion, right? Adding redundancy to a language is seldom a good idea.

Sure there is an 'explanation' for everything. Like the lawyers do.

Why don't you say you don't want to add because it means more work?

Reply by email

Mattias Gaertner
to Rainer Stratmann: For some days I have the mikroPascal Compiler from Mikroelektronika. And I am satisfied…
Show quoted text 11 lines
For some days I have the mikroPascal Compiler from Mikroelektronika. And I am satisfied with it. http://www.mikroe.com/mikropascal/avr With that product the declaration of an array is also possible with only one number. For example: var test : array[ 10 ] of byte;

For making porting code from other Pascal compilers easier fpc supports the modes (Delphi, TP, MacPas, ...). Do you think it is worth to add a new mikroPascal mode or modeswitch?

Like in C. That would make migration from C to Pascal easier. Is it posssible to integrate this in Freepascal also?

Compiling other languages syntax is not the goal of a Pascal compiler.
C to Pascal converters have this goal.

Mattias

Reply by email

Rainer Stratmann
to Mattias Gaertner: On Mon, 17 Jun 2013 22:06:46 +0200 For making porting code from other Pascal compilers…
you wrote
For making porting code from other Pascal compilers easier fpc supports the modes (Delphi, TP, MacPas, ...). Do you think it is worth to add a new mikroPascal mode or modeswitch?

Don't think that complicated.
For this 'revolutionary' feature there is no compiler switch necessary. Neither will it have influence on compatibility. Neither is it that difficult to implement.

Show quoted text 18 lines
> Like in C. > That would make migration from C to Pascal easier. > Is it posssible to integrate this in Freepascal also? Compiling other languages syntax is not the goal of a Pascal compiler. C to Pascal converters have this goal. Minimising the amount of required background knowledge and making everything self-explanatory is a fundamental part of the Pascal philosophy. Adding redundancy to a language is seldom a good idea. migration is easier but people might make mistakes when reading the code. well, to be honest, int hahaha[10] -> hahaha: array[0..9] of integer;

I should have known before.

Stupid me.

Reply by email

Fred van Stappen
to Fred van Stappen: Hum, do you know some good Pascal 2 C converter ? Yes, the world change in the past i was…
C to Pascal converters have this goal. Hum, do you know some good Pascal 2 C converter ? Yes, the world change in the past i was looking for good C2Pas or h2Pas, >now i need Pas2C converters...

Hum, to clarify, i need a Pas 2 C converter, not because i want to migrate to C, but because i have developped some libraries in Pascal and some C developpers want to use it...

Reply by email