Sign in Join

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

Mailing lists / fpc-pascal / 2001-04

Questions about the new features in version 1.2.

8 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

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

Keith Bowes

After seeing the page on planned compiler features, I've downloaded a version 1.1 snapshot and have tried out these new features; however, there are some things that I do not understand but feel that I should in case I need to use them in the future. I hope someone can explain these things to me.

1. What are Interfaces and Widestrings?

2. How do you get the upper and lower bounds of dynamic arrays when you don't already know those values for certain? When I use the High and Low functions for these things, I always get -1 and 0, respectively.

3. What are default parameters? Is it where you give parameters default values that are used if the parameter isn't passed when the function or procedure is called, kind of like optional arguments in JavaScript scripting?

Thank you very much and I'm very sorry if these questions have already been asked millions of times, but I couldn't access the archives.

Reply by email

Sebastian Günther
to Keith Bowes
Keith Bowes wrote
1. What are Interfaces and Widestrings?

An interface is similar to a class which consists only of virtual abstract methods. Additionally, it isn't derived from TObject or any other class; COM interfaces have a common ancestor called IUnknown. Technically, an interface is just a method table.

A WideString is a reference counted string of arbitrary length, just as AnsiStrings are; but they use 2 bytes per character to encode Unicode strings. (Currently, using UCS-2 encoding)

2. How do you get the upper and lower bounds of dynamic arrays when you don't already know those values for certain? When I use the High and Low functions for these things, I always get -1 and 0, respectively.

Just use Hi and Lo?

3. What are default parameters? Is it where you give parameters default values that are used if the parameter isn't passed when the function or procedure is called, kind of like optional arguments in JavaScript scripting?

Yes

- Sebastian

Reply by email

Jonas
Sebastian Günther wrote 5 lines
> 2. How do you get the upper and lower bounds of dynamic arrays when you > don't already know those values for certain? When I use the High and Low > functions for these things, I always get -1 and 0, respectively. Just use Hi and Lo?

No, high() and low() should work (hi and lo are for getting the upper/lower part of bytes/words/longints/int64s etc).

To Keith Bowes : could you show an example program that fails? And which version of the compiler are you using? (use the command line option -i)

Jonas

Reply by email

Gabor DEAK JAHN
to Sebastian Günther: An interface is similar to a class which consists only of virtual abstract methods.…

At 4/9/01 10:27 AM, you wrote:

Sebastian,

An interface is similar to a class which consists only of virtual A WideString is a reference counted string of arbitrary length, just as

Could you give us a very rough estimate of when these could be expected in a stable release? I know that such things are very hard to predict and I don't want to call you to account with a set date, but I would like to have an idea whether it could be weeks, months or years? I'd need both quite badly (Unicode strings are the number one for me, COM interfaces, although with some additional work, can be worked around).

Also, will there be a non-reference counted Unicode string as well? Many Win32 function require that, just like a PChar but made up of words instead of bytes.

Bye,
   Gábor

------------------------------------------------------------------- Gabor DEAK JAHN -- Budapest, Hungary.
E-mail: ,

Reply by email

Sebastian Günther
to Gabor DEAK JAHN
Gabor DEAK JAHN wrote 11 lines
At 4/9/01 10:27 AM, you wrote: Sebastian, > An interface is similar to a class which consists only of virtual > A WideString is a reference counted string of arbitrary length, just as Could you give us a very rough estimate of when these could be expected in a stable release?

Don't ask me, these features are only available in FPC 1.1, so you would have to wait until 1.1 stabilizes. Which might take some time; I'm not happy about this either, but I cannot influence this. The compiler guys want some other stuff in 1.1 before a new major release will be built.

I know that such things are very hard to predict and I don't want to call you to account with a set date, but I would like to have an idea whether it could be weeks, months or years?

(Florian? Any estimate?)

I'd need both quite badly

me too...

Also, will there be a non-reference counted Unicode string as well? Many Win32 function require that, just like a PChar but made up of words instead of bytes.

PWideChar should do the job (although I don't think that it is fully implemented in FPC yet. The whole Unicode support is not really complete or tested, but hopefully this will be done within the next few weeks.)

WideString itself will always be reference counted, as it is the case with Kylix and Delphi >=6.0

But you can always cast a WideString to a constant PWideChar with zero overhead; just the way you can use AnsiStrings with constant PChar arguments.

- Sebastian

Reply by email

Schalk
to Keith Bowes: After seeing the page on planned compiler features, I've downloaded a version 1.1…

Keith,

I believe I am much more of an amateur at Freepascal than you, so I can't help you.

I myself have some questions to ask. I see so many advantages of usings Freepascal rather than the old Pascal, yet I need to learn how to use this version. I have trouble compiling my own units, or importing my old units and recompiling them with the Freepascal compiler.

Wether it will help or not, I would like to download the full version again (Windows and Dos) and reinstall it.

So, can you please give me the link to where you downloaded your Freepascal?

Earlier message 33 lines
----- Original Message ----- From: Keith Bowes To: Sent: Monday, April 09, 2001 5:10 AM Subject: [fpc-pascal]Questions about the new features in version 1.2. > After seeing the page on planned compiler features, I've downloaded a > version 1.1 snapshot and have tried out these new features; however, there > are some things that I do not understand but feel that I should in case I > need to use them in the future. I hope someone can explain these things to > me. > > 1. What are Interfaces and Widestrings? > > 2. How do you get the upper and lower bounds of dynamic arrays when you > don't already know those values for certain? When I use the High and Low > functions for these things, I always get -1 and 0, respectively. > > 3. What are default parameters? Is it where you give parameters default > values that are used if the parameter isn't passed when the function or > procedure is called, kind of like optional arguments in JavaScript > scripting? > > Thank you very much and I'm very sorry if these questions have already been > asked millions of times, but I couldn't access the archives. > > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal >

Reply by email

Keith Bowes
to Jonas: No, high() and low() should work (hi and lo are for getting the upper/lower part of…
To Keith Bowes : could you show an example program that fails?

Sure. Here's a small test case:

Program Test;
Var
    A: Array Of String;
    I: Integer;
Begin
    SetLength(A, 3);
    A[1] := 'String 1';
    A[2] := 'String 2';
    A[3] := 'String 3';
    WriteLn('Upper bound: ', High(A));
    WriteLn('Lower bound: ', Low(A));
    WriteLn('Elements of the array:');
    For I := Low(A) To High(A) Do
        WriteLn('Array element ', I, ': ', A[I]);
    Halt;
End.
And which version of the compiler are you using? (use the command line

option -i)
Here's the output I got using the -i option:

Free Pascal Compiler version 1.1

Compiler Date : 2001/04/04
Compiler Target: i386

This program comes under the GNU General Public Licence For more information read COPYING.FPC

Report bugs,suggestions etc to:

Reply by email