Pascal syntax and features of latest compiler versions

General discussion on mikroPascal.
Post Reply
Author
Message
rainer
Posts: 320
Joined: 07 Dec 2006 11:00
Location: Vienna, Austria
Contact:

Pascal syntax and features of latest compiler versions

#1 Post by rainer » 09 Feb 2009 18:41

Hi,

I have some questions on mikroPascal:

:arrow: Pre-assigning a value to a var
In normal pascal language (TurboPascal, Borland-Pascal, FreePascal, ...), I can do this:

Code: Select all

var
  varname : integer = 12;

begin
  writeln(varname);  // writes now "12"
  varname:=22;
  writeln(varname);   // writes now "22"
end.
MikroPascal rises an error if I try to define a variable this way. When will this be possible? My version 8.1 and all versions before do not support it.



:arrow: Visibility of code+vars in units:
Do units meanwhile have a really working separation of their interface and implementation section, allowing me to write procedures/functions and to define vars which are only visible within the unit, while some procedures/functions/vars are visible from outside?

As far as I can remember, "interface" is not understood and all code is visible. This makes it difficult to write good code with capsulated units.

rainer

piort
Posts: 1379
Joined: 28 Dec 2005 16:42
Location: Laval,Québec,Canada,Earth... :-)
Contact:

#2 Post by piort » 09 Feb 2009 19:58

hi rainer,

if they make a big step in pascal syntax i will prefert the implentation of 'with' statement for record and string type and predefine lib....
exemple :

Code: Select all

var my_str : string[5];
var my_rec : Tmy_rec;

type Tmy_rec = record
       my_var : integer;
       my_var_2 : string [5];
      end;

while true do
   begin
     my_str := 'allo';
  
       with my_rec do
          my_var := 1;
          my_var_2 := my_str;
        end;

        with usart do
          init;
          for i = 0 to 5 do
              with my_rec.my_var_2 do
                write_char( [i] );   // send by usart each char of the string ;-)
               end;   
         end;

end.


cfbsoftware
Posts: 63
Joined: 20 May 2008 13:16
Contact:

#3 Post by cfbsoftware » 10 Feb 2009 00:28

piort wrote:if they make a big step in pascal syntax i will prefert the implentation of 'with' statement for record and string type and predefine lib....
I believe this would be a backward step. Although the 'with' facility persisted in Modula-2 after Pascal, experience eventually showed that explicitly qualified record fields were preferable. Niklaus Wirth finally removed the 'with' feature in the design of Oberon around 1990. Have a look at the current discussion raging in the Delphi non-technical newsgroups for many good reasons why 'with' is NOT a good idea.

https://forums.codegear.com/forum.jspa?forumID=67

The relevant discussions have the following two subject lines

Advice requested on "with"
(.Stob.)
Chris Burrows
Astrobe: Cortex-M3, Cortex-M4 and ARM7 Oberon Development System
http://www.astrobe.com

piort
Posts: 1379
Joined: 28 Dec 2005 16:42
Location: Laval,Québec,Canada,Earth... :-)
Contact:

#4 Post by piort » 10 Feb 2009 03:44

hi,
i agree against abusive use of 'with' statement but the most prob those link told me is about specific issue in OOP ... We are far to work with OOP with MCU compiler... Maybe im wrong ( that happens sometime lol) but here we are talking with a pascal compiler more in style of the nice but old and not OOP borland turbo pascal (for dos) ... oups that give my age )))

After reading all those comment i still think a intelligent use of 'with' can save time and make more readable code... in fact, i start to program with turbo pascal in dos time and following delphi since version one... and i never had any problem with 'with' statement ... but maybe because im a lucky guys ))))

that my 2 cents ;-)

User avatar
zristic
mikroElektronika team
Posts: 6608
Joined: 03 Aug 2004 12:59
Contact:

#5 Post by zristic » 10 Feb 2009 10:25

The with statement will be implemented in the next release. It is under test and proved to be working OK.

For the rest of the questions/comments I will reply later.

joseLB
Posts: 444
Joined: 02 Apr 2006 05:56
Location: Riode Janeiro, Brasil

#6 Post by joseLB » 12 Feb 2009 21:29

zristic wrote:The with statement will be implemented in the next release. It is under test and proved to be working OK.
Zoran, by the way:
1- "with" don't work on v6.x? I was loving your example above
2- by the way, when do you think we will have this so awaited new version? :roll:
Jose

User avatar
zristic
mikroElektronika team
Posts: 6608
Joined: 03 Aug 2004 12:59
Contact:

#7 Post by zristic » 13 Feb 2009 14:52

joseLB wrote:1- "with" don't work on v6.x? I was loving your example above
2- by the way, when do you think we will have this so awaited new version? :roll:
1. It works only in the PRO version for mikroPascal for PIC compiler, the beta of which is
2. Coming out in the beginning of March 2009.

piort
Posts: 1379
Joined: 28 Dec 2005 16:42
Location: Laval,Québec,Canada,Earth... :-)
Contact:

#8 Post by piort » 13 Feb 2009 22:44

hi Zoran,

the beta in 3 week ??? that too long ! what do you i do in the mid time ??? i will discover i still have kids at home !!! LOLOLOL

joseLB
Posts: 444
Joined: 02 Apr 2006 05:56
Location: Riode Janeiro, Brasil

#9 Post by joseLB » 14 Feb 2009 12:02

zristic wrote:... Coming out in the beginning of March 2009.
Uau! Great! :P :lol:

Post Reply

Return to “mikroPascal General”