Re: [fpc-pascal] dynamic array as a part of dynamically allocated records behavior

2012-02-25 Thread Mattias Gaertner
On Sat, 25 Feb 2012 04:23:24 -0800 (PST)
leledumbo leledumbo_c...@yahoo.co.id wrote:

 Consider the following program:
 
 {$mode objfpc}
 type
   TJam = array of Integer;
 
   TRuang = record
 nm_ruang: string;
 avl: TJam;
   end;
 
   PRuang = ^TRuang;
 
 var
   x: array of integer;
   TR: TRuang;
   PR: PRuang;
 begin
   try
 WriteLn(Length(x));
 WriteLn(Length(TR.avl));
 PR := GetMem(SizeOf(TRuang));

New(PR);

 WriteLn(Length(PR^.avl));
   finally
 FreeMem(PR);

Dispose(PR);

   end;
 end.
 
 
 The code results in AV in the last WriteLn. Is this correct (i.e. intended
 behavior)? If yes, what is the correct way to have the PR^.avl initialized
 just like TR.avl and x?

New is GetMem+Initialization.
Dispose is Finaliziation+FreeMem.

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] dynamic array as a part of dynamically allocated records behavior

2012-02-25 Thread Jonas Maebe

On 25 Feb 2012, at 13:23, leledumbo wrote:

 The code results in AV in the last WriteLn. Is this correct (i.e. intended
 behavior)?

Yes.

 If yes, what is the correct way to have the PR^.avl initialized
 just like TR.avl and x?

Use new(PR) instead of GetMem(SizeOf(TRuang)), or alternatively call 
initialize(PR^) after calling getmem (which new() does for you automatically).


Jonas___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Re: dynamic array as a part of dynamically allocated records behavior

2012-02-25 Thread leledumbo
 New is GetMem+Initialization. 
 Dispose is Finaliziation+FreeMem. 

Working GR8, thanks! I didn't know about above equation until just now :p

--
View this message in context: 
http://free-pascal-general.1045716.n5.nabble.com/dynamic-array-as-a-part-of-dynamically-allocated-records-behavior-tp5515029p5515071.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FPC with case insensitive file system under Linux

2012-02-25 Thread Graeme Geldenhuys
On 24 February 2012 16:13, Henry Vermaak wrote:

 Because case sensitive systems don't create as much confusion.


Here my thoughts are the opposite. While backing up my data no an
external drive with is case insensitive I came across a lot of
possible issues I never realised I had on my case sensitive Linux file
system.

eg:
  In one source code directory I had files as follows:
   tiDefines.inc
   tidefines.inc

Backing this up to a case insensitive file system, I program prompted
me that the origin file was going to be replaced? So, looking at those
files on my Linux (case sensitive) file system, which one is actually
the latest version? To find out, I had to fire up Beyond Compare and
to a content comparison.

This actually happened quite a few times with many of my source code.
This all probably got introduced when I moved source code over from
Windows to Linux some 6 years ago.

Confusing now? Definitely! Did Linux warn me, nope. Does the compiler
know which one to actually use - no idea. How does Lazarus know which
one to open (because Lazarus searches for multiple case files) - no
idea?


Then lets look at it from an average user's point of view. Must they
really be confronted with multiple files in a single folder named:

   test.txt
   Test.txt
   Test.Txt
   TEST.TXT
   test.TXT
   

All the user wants to do, is open a test dot t x t file. Under Linux
they could be confronted with multiple versions? Very confusing.

I like to CamelCase my file names - it makes them easier to read in a
file listing. But when I reference them in say a search dialog, I'll
probably type them in all lowercase for speed reason. I would still
like Linux to find that file though - but it wouldn't.

As I, and it seems many others on the Internet, have found - there
really isn't a good reason why Linux must still use case sensitive
file systems. Windows supports multiple locales and has 95% of the
computer market - it doesn't have case sensitive file systems. Mac OS
X by default doesn't either (though they are nice enough to give you
the choice). I think Linux should give you the choice too.

Anyway, hopefully my newly formatted JFS partitions will sort this out.


  At the end of the day, a computer thinks that a is 97 and A is 65, but
 what humans perceive is more complicated.

And a computer should serve a human, not the other way round.  Read
the excellent book About Face 3.


-- 
Regards,
  - Graeme -


___
fpGUI - a cross-platform Free Pascal GUI toolkit
http://fpgui.sourceforge.net
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FPC with case insensitive file system under Linux

2012-02-25 Thread Graeme Geldenhuys
On 24 February 2012 15:57, Mattias Gaertner wrote:

 The whole last week I cursed the opposite direction (first windows, then OS 
 X).
 It seems it depends on the current task.

:-)


 Linux can handle both. But many Linux tools only support case sensitive
 files.

Well, in a case insensitive file system, there will only be one copy
of a specific file name in a directory. So the Linux tools should get
confused with which one to open or use. So I don't really think it is
going to be a problem.  I guess I'll find out in the coming week.  :-)


 My recommendation: If you have the choice, use the OS defaults.
 Many programs will fail otherwise.

In the case of Linux, there is no default. Linux is just the kernel.
The Linux distro's on the other hand all make different choices. Some
distros choose ReiserFS, others Ext3, others Ext4, others JFS, some
are now experimenting with Btrfs etc.

Anyway, our company has done extensive testing (a couple years ago)
with performance and failure recovery of various file systems for
Linux, and JFS has come up tops. I personally have standardised on JFS
for many years. Only now am I deciding to switch to the case
insensitive option though. Luckily I have a choice under Linux.

Anyway, I just wanted to know if anybody knew of any blatant issues
with FPC or Lazarus on a case insensitive file system, but I guess
with Windows and Mac OS X being around, it is safe to assume
everything will continue to work as normal.

-- 
Regards,
  - Graeme -


___
fpGUI - a cross-platform Free Pascal GUI toolkit
http://fpgui.sourceforge.net
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FPC with case insensitive file system under Linux

2012-02-25 Thread Jürgen Hestermann

Graeme Geldenhuys schrieb:
 On 24 February 2012 16:13, Henry Vermaak wrote:
 Because case sensitive systems don't create as much confusion.
 Here my thoughts are the opposite. While backing up my data no an
 external drive with is case insensitive I came across a lot of
 possible issues I never realised I had on my case sensitive Linux file
 system.
 eg:
   In one source code directory I had files as follows:
tiDefines.inc
tidefines.inc
 Backing this up to a case insensitive file system, I program prompted
 me that the origin file was going to be replaced? So, looking at those
 files on my Linux (case sensitive) file system, which one is actually
 the latest version? To find out, I had to fire up Beyond Compare and
 to a content comparison.
 This actually happened quite a few times with many of my source code.
 This all probably got introduced when I moved source code over from
 Windows to Linux some 6 years ago.
 Confusing now? Definitely! Did Linux warn me, nope. Does the compiler
 know which one to actually use - no idea. How does Lazarus know which
 one to open (because Lazarus searches for multiple case files) - no
 idea?
 Then lets look at it from an average user's point of view. Must they
 really be confronted with multiple files in a single folder named:
test.txt
Test.txt
Test.Txt
TEST.TXT
test.TXT

 All the user wants to do, is open a test dot t x t file. Under Linux
 they could be confronted with multiple versions? Very confusing.
 I like to CamelCase my file names - it makes them easier to read in a
 file listing. But when I reference them in say a search dialog, I'll
 probably type them in all lowercase for speed reason. I would still
 like Linux to find that file though - but it wouldn't.
 As I, and it seems many others on the Internet, have found - there
 really isn't a good reason why Linux must still use case sensitive
 file systems. Windows supports multiple locales and has 95% of the
 computer market - it doesn't have case sensitive file systems. Mac OS
 X by default doesn't either (though they are nice enough to give you
 the choice). I think Linux should give you the choice too.


 Anyway, hopefully my newly formatted JFS partitions will sort this out.
  At the end of the day, a computer thinks that a is 97 and A is 
65, but

 what humans perceive is more complicated.
 And a computer should serve a human, not the other way round.  Read
 the excellent book About Face 3.


I wholeheartly agree with you on case sensitive file names. It's a crap.
I never understood why they created such a nonsense.
And now generations of Linux users have to suffer from it.
For me it's one of the last obstacles on the way to Linux.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] OT: Amazing new development tools

2012-02-25 Thread ik
Hello,

I found the following amazing lecture that present a new idea of a
development tool, that I think will interest you all:

http://vimeo.com/36579366

Enjoy
Ido
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] OT: Amazing new development tools

2012-02-25 Thread Vinzent Höfler

On Sat, 25 Feb 2012 19:15:54 +0100, ik ido...@gmail.com wrote:


I found the following amazing lecture that present a new idea of a
development tool, that I think will interest you all:

http://vimeo.com/36579366


Impressive, indeed. And I am usually not that easily impressed.


Vinzent.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal