Re: [fpc-pascal] PChar & AnsiString

2010-06-01 Thread spir
On Tue, 01 Jun 2010 16:30:22 +0100 Martin wrote: > I don't know all the internals of FPC, but yes to my understanding, your > quote: >"parameter passing is just an implicit assignment" > is absolutely true. > > So why do you then say "copy on write" would not apply? > The assignment creates

Re: [fpc-pascal] timing again

2010-06-01 Thread spir
On Tue, 01 Jun 2010 19:58:54 +0200 "Vinzent Höfler" wrote: > "spir ☣" : > > > Thank you. Using dos.getTime (including its last arg), the following > > returns integer time in 10^-2s units: > [...] > > > > This is the needed base for my

[fpc-pascal] array & record output/input

2010-06-02 Thread spir
Hello, Is there a (builtin, simple) way to output the content of an array or of a record. Something like arrayToStr / recordToStr, that would return a normal form similar to the literal notation used for intialisation? If no, is there a way to write custom funcs for this purpose (meaning acces

Re: [fpc-pascal] PChar & AnsiString

2010-06-02 Thread spir
On Wed, 2 Jun 2010 15:19:55 +0700 Bee Jay wrote: > On 1 Jun 2010, at 22:13, spir ☣ wrote: > > > (*) And to some more constructs in other languages, like foreach (*the* > > feature I miss in freepascal): > > foreach name in names do ... end; > > http://w

Re: [fpc-pascal] PChar & AnsiString -- for-in loop enumerator

2010-06-02 Thread spir
On Wed, 2 Jun 2010 15:19:55 +0700 Bee Jay wrote: > On 1 Jun 2010, at 22:13, spir ☣ wrote: > > > (*) And to some more constructs in other languages, like foreach (*the* > > feature I miss in freepascal): > > foreach name in names do ... end; > > http://wiki.

Re: [fpc-pascal] PChar & AnsiString

2010-06-02 Thread spir
On Wed, 2 Jun 2010 14:30:15 +0200 Graeme Geldenhuys wrote: > On 2 June 2010 14:16, Marco van de Voort wrote: > > > > Afaik it is merged into 2.4.1 already. > > > Did somebody actually test it other than Paul (that also implemented > it)? If so, that was a rather quick test for a big compiler c

[fpc-pascal] method renaming

2010-06-03 Thread spir
Hello, Is it possible to rename a method in a subclass (with or without overriding); for instance because the new name makes more sense in the subclass? In my case, the situation is a bit different: a single method splits into two methods in a subclass. One is equivalent to the inherited one, b

[fpc-pascal] compiler / language //

2010-06-04 Thread spir
Hello, I just discovered a set of wiki pages about freepascal's compiler: http://wiki.lazarus.freepascal.org/FPC_internals. On can find at http://wiki.lazarus.freepascal.org/Symbol_tables the following table (a bit refactored here). The Symbol table object All symbol tables in the compiler

[fpc-pascal] compiler / language // ----- sending error

2010-06-04 Thread spir
*** Sorry, I sent this post to the wrong list. Hope you find it interesting anyway ... Hello, I just discovered a set of wiki pages about freepascal's compiler: http://wiki.lazarus.freepascal.org/FPC_internals. On can find at http://wiki.lazarus.freepascal.org/Symbol_tables the following tab

[fpc-pascal] Pascal dialect -- was: Re: fpc-pascal Digest, Vol 72, Issue 12

2010-06-04 Thread spir
On Fri, 04 Jun 2010 08:50:06 +0200 Graeme Geldenhuys wrote: > Borland and Embarcadero jumps off > the cliff - FPC must now also jump off the cliff. :) Hello, Graeme! I'm surprised of this, fpc still systematically trying to follow Delphi, after so many years. I can understand that at the begin

Re: [fpc-pascal] Pascal dialect -- was: Re: fpc-pascal Digest, Vol 72, Issue 12

2010-06-04 Thread spir
On Fri, 4 Jun 2010 13:21:09 +0200 (CEST) Michael Van Canneyt wrote: > And to be honest, I think we do a very good job of it. Yes, we don't have > 100% compatibility. But no, it's never 100%. But it is certainly good > enough to satisfy most people that need it. Hello, Michael! No doubt about t

[fpc-pascal] random question

2010-06-04 Thread spir
Hello Pascaleers, -1- class wrappers Are there in stock implementations of class wrappers for primitive types: such as TInteger, TString, etc? (that would for instance just hold a .value attr and delegate operations to builtin funcs or procs) This would save me some work :-) -2- [] operator Ho

[fpc-pascal] linking name issue

2010-06-05 Thread spir
Hello, I have renamed a unit previously called "UnitType" to "UnitSystem". The unit name itself, its file name, and the name used to import it in a uses clause inside a testing program where all changed. But the linker still expects the previous name: testUnit.pas(78,1) Warning: Object UnitType.

Re: [fpc-pascal] regex vs synregexpr unit

2010-06-05 Thread spir
On Sat, 5 Jun 2010 09:54:51 -0700 (PDT) Bihar Anwar wrote: > I've search fpc mailing list about this matter, I found they were discussed a > long time ago (2006), and I still didn't have a conclusion about which one > should be used. I need an advice about which unit should be used in terms of

Re: [fpc-pascal] [SOLVED] linking name issue

2010-06-05 Thread spir
On Sat, 5 Jun 2010 11:13:31 -0700 David Emerson wrote: > Try deleting testunit.o and/or testunit.a, testunit.ppu Yes, there was another unit still referencing "UnitType" -- but not used by the TestUnit test prog. Strange that it may prevent testUnit to compile and link. Anything, deleted all bu

[fpc-pascal] reference model for class instances

2010-06-16 Thread spir
Hello, After having read the draft standard proposel for OO extensions for Pascal, esp. the Object Model (http://www.pascal-central.com/OOE-stds.html#sect-6.5.1), I wonder how implicite (de)referencing of class instances is actually implemented in fpc (Delphi-like OO). In particuliar, when is (

[fpc-pascal] Do you get type errors?

2010-06-20 Thread spir
Hello, Theoretically speaking, I'm all for type checking; and for programming discipline in general. But in practice I never get type errors. What the compiler complains about is all kinds of plain grammatical errors: * typos * missing ';' (many) * wrong number of 'end' * name error * signature

Re: [fpc-pascal] Do you get type errors?

2010-06-20 Thread spir
On Sun, 20 Jun 2010 16:07:08 +0200 Jürgen Hestermann wrote: > e:) > > * What is type checking _actually_ useful for? > > I would be lost without type checking, > especially when using sophisticated data structures > like pointers to arrays of records (which again > contain pointers to other comp

Re: [fpc-pascal] Static Initialisation of Arrays

2010-06-28 Thread spir
On Mon, 28 Jun 2010 18:17:47 +0200 Jürgen Hestermann wrote: > > > Paul Michell schrieb: > > I realise that 'Array Of Single' declares a dynamic array, but is there > > any equivalent syntax for static data arrays in the same way that > > strings litterals are in effect, variable length static

Re: [fpc-pascal] methods of an object to create others objects

2010-07-05 Thread spir
On Mon, 5 Jul 2010 15:48:40 -0300 Marcos Douglas wrote: Questions of style: just a personal opinion. > We can to use methods of an object to create others objects, or this > is a bad programming practice? > eg: > var > obj1, obj2: TmyObject; > begin > obj1 := tobj1.create; //ok > obj2 := o

Re: [fpc-pascal] methods of an object to create others objects

2010-07-05 Thread spir
On Mon, 5 Jul 2010 16:51:54 -0300 Marcos Douglas wrote: > >> Why I ask this: > >> If not exists the variable obj2 in call obj1.createObj will happen a > >> memory leak, right? Because there is not variable to release. > > > > Do you mean using a function as a statement? (for its so-called "side

[fpc-pascal] "start" Lazarus

2010-04-16 Thread spir
Hello, Newcomer here. Seems stupid, but I had a hard time in simply starting Lazarus -- on Ubuntu. When I typed "lazarus", I got an error message about a lazarus program from another package. Finally thought at the "Application" menu, which I else never use. Then, copying the launcher to the de

Re: [fpc-pascal] "start" Lazarus

2010-04-18 Thread spir
On Sat, 17 Apr 2010 16:46:50 +0200 Mattias Gaertner wrote: > On Sat, 17 Apr 2010 16:11:48 +0200 > Ritchie Flick wrote: > > > > > On Apr 16, 2010, at 6:40 PM, spir ☣ wrote: > > > > > Hello, > > > > > > Newcomer here. > > > Seems

Re: [fpc-pascal] "start" Lazarus

2010-04-18 Thread spir
On Sun, 18 Apr 2010 19:35:16 +0200 Mattias Gaertner wrote: > On Sun, 18 Apr 2010 19:25:53 +0200 > spir ☣ wrote: > > >[...] > > > It is true that there is an older package tct with a binary > > > 'lazarus' (to revive partitions). > > > So

[fpc-pascal] newbie questions

2010-04-19 Thread spir
Hello, Total Pascal newbie here. Looked for answers in various references and tutorials, but cannot find. Fore-question: Is there a (free)pascal teaching/learning mailing list? (Like python's "tutor" list.) If not, is this one a proper place? * How does one declare the type of set items? nu

Re: [fpc-pascal] newbie questions

2010-04-19 Thread spir
On Mon, 19 Apr 2010 16:36:06 +0100 Howard Page-Clark wrote: > On 19/4/10 3:50, spir ☣ wrote: > > Hello, > > > > Total Pascal newbie here. Looked for answers in various references and > > tutorials, but cannot find. > > > > Fore-question: Is there a (fre

Re: [fpc-pascal] newbie questions

2010-04-22 Thread spir
On Tue, 20 Apr 2010 01:17:51 +0200 Marc Weustink wrote: > Somehow I get the idea that you mix the definition/use of sets with arrays. Yes, it seems Pascal sets are rather related to enums than collections. I mean they look like packs of kinds of flags, which themselves are named but value-free

[fpc-pascal] pointer to anything

2010-04-23 Thread spir
Hello, Say I want to implement a kind of linked list which node data may be anything. Thus I cannot store data on place (in nodes), indeed; so it should be referenced. But pointers themselves are supposed to be typed. So, how can I do that? type list = ^node; node = record data : ?

Re: [fpc-pascal] pointer to anything

2010-04-23 Thread spir
On Fri, 23 Apr 2010 08:17:21 -0400 Doug Chamberlin wrote: > On 4/23/2010 3:33 AM, spir ☣ wrote: > > Say I want to implement a kind of linked list which node data may be > > anything. Thus I cannot store data on place (in nodes), indeed; so it > > should be referenced. Bu

[fpc-pascal] pointer magic

2010-04-27 Thread spir
Hello, Two basic questions about pointer targets (I call target what is pointed to). -1- untyped pointer allocation In case of an untyped pointer, I read the compiler considers the target'size is 1 byte. There certainly is an operation to allocate memory for the target according to an existing

[fpc-pascal] re-newing a pointer

2010-04-28 Thread spir
Hello, It seems that once a pointer has been assigned nil, it needs to be (re)allocated using new() before using it to (re)set its target: ... p := nil; // pointer to Integer ... new(p) ; p^ := 1; Is this hypothesis correct? Use case: Linked List nil is used in the "toNext" field of a li

[fpc-pascal] compilation feeback

2010-04-30 Thread spir
Hello, 3 little questions about messages: -1- "local" variable When a program-global variable is unused, the compiler message reads 'Note: Local variable "x" not used'. Is this a mistake or do I misunderstand some point? -2- place of error messages In the output, warnings seem to always come be

Re: [fpc-pascal] compilation feeback

2010-04-30 Thread spir
On Fri, 30 Apr 2010 09:52:44 +0200 Graeme Geldenhuys wrote: > > '/use/bin/ld: warning: link.res contains output sections; did you forget > > -T?' > > What does this mean? > > I get this often, and also don't have a clue what it means. Yet our > applications still seem to run fine. Go figure??

Re: [fpc-pascal] compilation feeback

2010-04-30 Thread spir
On Fri, 30 Apr 2010 09:51:44 +0200 Jonas Maebe wrote: > > On 30 Apr 2010, at 09:40, spir ☣ wrote: > > > -1- "local" variable > > When a program-global variable is unused, the compiler message reads > > 'Note: Local variable "x" not use

[fpc-pascal] var parameter

2010-04-30 Thread spir
Hello, I wrote a little simulation prog to try and understand better the semantics of var parameters (see below code and output). It seems they behave like if passed via pointers, but also locally _operated_ via pointers. Meaning there is in ChangeVar no real local variable n (on the stack). B

[fpc-pascal] method order

2010-04-30 Thread spir
(Note: I use "method" for "either procedure or function"; if there is a proper term, please tell me --I don't know any.) Hello, A short question: Why must a called method be defined before the caller, since it will be called only at runtime? Also: what is the trick then (on the implementation s

Re: [fpc-pascal] method order

2010-05-01 Thread spir
On Fri, 30 Apr 2010 19:17:51 +0200 Mattias Gaertner wrote: > Maybe you don't know 'forward'? Thank you! Denis vit esse estrany ☣ spir.wikidot.com ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://li

[fpc-pascal] linked list to criticize

2010-05-02 Thread spir
Hello, Finally did it! Managed to write in Pascal a linked list type, with all common operations (put, change, remove, find & more). If anyone is nice enough to have a look, comment, and criticize: http://spir.wikidot.com/pascal-doubly-linked-list (There's an extensive intro text, and a test suit

[fpc-pascal] optional parameter

2010-05-03 Thread spir
Hello, A few questions on the topic: * Is it possible to define an optional parameter without default value? * Is it at all possible for an optional *argument* not to be the last in actual call? Eg procedure p(a:Integer=0 ; b:Integer=0) How can the caller pass b and not a? * The ref sta

Re: [fpc-pascal] linked list to criticize

2010-05-03 Thread spir
On Mon, 3 May 2010 16:02:32 +1000 "Paul Nicholls" wrote: > Hi Denis, > nice :) > > I'm curious, why didn't you make it a class...wouldn't that have made it > nicer/easier to use and program? Yes, for sure. Not beeing able to use the OO syntax is really a pain! (Even inside the LinkedList uni

Re: [fpc-pascal] linked list to criticize

2010-05-03 Thread spir
On Sun, 2 May 2010 22:20:43 +0200 Felipe Monteiro de Carvalho wrote: > Hello, > > I think it would be good if you add a link to your package here: > > http://wiki.lazarus.freepascal.org/Components_and_Code_examples > Thanks, I'll add it there if some of you test it. (Self-testing one's own to

Re: [fpc-pascal] optional parameter

2010-05-03 Thread spir
On Mon, 03 May 2010 19:15:57 +0100 Martin wrote: > On 03/05/2010 10:58, spir ☣ wrote: > > Hello, > > > > A few questions on the topic: > > > > * Is it possible to define an optional parameter without default value? > > > > * Is it at all possible for

Re: [fpc-pascal] optional parameter

2010-05-03 Thread spir
On Mon, 3 May 2010 14:28:13 -0300 Flávio Etrusco wrote: > > Needed to change the > > parameter to be a pointer to the record instead (so the default can be > > nil), but this creates a > > trap for the calling code. > > Else, is there a common trick or workaround? > > > > What trap? Simply t

Re: [fpc-pascal] dynamic array contents and system.move

2010-05-05 Thread spir
On Tue, 4 May 2010 23:49:00 +0200 José Mejuto wrote: > In computer science, an array data structure or simply array is a > data structure consisting of a collection of elements (values or > variables) [...] ??? What does this mean? As far as I know, "variable" in CS can have 3 senses, depending

Re: [fpc-pascal] dynamic array contents and system.move

2010-05-05 Thread spir
On Wed, 05 May 2010 07:34:41 +0200 Jürgen Hestermann wrote: > Say that it is a pointer to an array (and do not let the user think it is "an > array"!). And say that although it is a pointer you still cannot derefference > it but you need to use the first index to get the beginning of the array.

[fpc-pascal] Pascal pointer life cycle

2010-05-05 Thread spir
Hello, First, I found a very good introduction material to pointers at http://cslibrary.stanford.edu/. The author, "Nick Parlante" (nickname?) really has a great pedagogical talent. Below some code and output tracing a typical pointer's life cycle: === code === procedure PointerLifeCyc

Re: [fpc-pascal] dynamic array contents and system.move

2010-05-05 Thread spir
On Wed, 5 May 2010 13:44:40 +0200 José Mejuto wrote: > The same applies to Pascal, my previous example is badly designed, but > better than the first one. The problem here is try to use "move" as a > Pascal way of do things. Move is low level function that should be > used to optimize code when y

[fpc-pascal] about dynamic array

2010-05-06 Thread spir
Hello, Where can one find information on types like dynamic array? Also, on funcs or procs that apply on them, like setLength & copy. If the answers to the following questions are somewhere, just tell me... * Can one rely on the fact that setLength keeps existing data (in the range of the ne

[fpc-pascal] about dynamic array -- PS

2010-05-06 Thread spir
Hello, It seems the actual issue with static array is that the size is part the type. So that one cannot even use a pointer to refer to an array which size is supposed to change (since the pointer's type itself would be constrained by the size). Is this correct? If yes, how is it possible to bu

[fpc-pascal] standard unit description -- builtin funcs & procs

2010-05-06 Thread spir
Hello, It seems, maybe, that most people using freepascal actually come from a different environment (esp Delphi) with all needed knowledge about (a dialect of) the language itself, here in fact Pascal *and* object Pascal; and also about its major utilities (& common libraries). How do *real* n

Re: [fpc-pascal] about dynamic array

2010-05-06 Thread spir
On Thu, 6 May 2010 12:16:22 +0200 Graeme Geldenhuys wrote: > 2010/5/6 spir ☣ : > > > > If the answers to last 2 questions is "only every 29th of februar", how can > > one have a "flexible" array? Is there something like that in stock? Would > &g

Re: [fpc-pascal] about dynamic array

2010-05-06 Thread spir
On Thu, 6 May 2010 16:20:58 +0200 José Mejuto wrote: > Hello FPC-Pascal, > > Thursday, May 6, 2010, 3:53:59 PM, you wrote: > > c> TList wraps TFPList, which is based internally on an array. So access > c> is fast; insertion, deletion not. > > But it is faster than inserting elements in a dynam

Re: [fpc-pascal] about dynamic array

2010-05-06 Thread spir
On Thu, 6 May 2010 12:10:39 -0300 Flávio Etrusco wrote: > On Thu, May 6, 2010 at 11:58 AM, Florian Klaempfl > wrote: > > José Mejuto schrieb: > >> Hello FPC-Pascal, > >> > >> Thursday, May 6, 2010, 3:53:59 PM, you wrote: > >> > >> c> TList wraps TFPList, which is based internally on an array. So

Re: [fpc-pascal] Where is the best place to declare an array?

2010-05-07 Thread spir
[OT -- not fpc-related -- just a side note] On Fri, 7 May 2010 00:34:11 +0200 Jonas Maebe wrote: > in general my bias would be much more against than in favour of global > variables from a speed perspective In _some_ dynamic languages using a virtual machine at least (eg Lua), local variables

Re: [fpc-pascal] about dynamic array

2010-05-07 Thread spir
On Fri, 7 May 2010 06:10:30 +0200 cobines wrote: > 2010/5/6 spir ☣ : > > (By the way, started playing with TFPList already, and could not find how > > to get data back! I mean the symtric of add(). Even tried indexing (who > > knows, with the syntactic magic of modern la

Re: [fpc-pascal] about dynamic array -- p

2010-05-07 Thread spir
On Fri, 7 May 2010 06:10:30 +0200 cobines wrote: PS : I also need the pointer's mediation when a func/proc expects a (typed) element. Must rewrite the code to use an element pointer as parameter (and pass a pointer from the list). This is more annoying since it obscures the func/proc's signat

Re: [fpc-pascal] standard unit description -- builtin funcs & procs

2010-05-07 Thread spir
On Fri, 7 May 2010 11:09:42 +0200 (CEST) "Tomas Hajny" wrote: > > http://www.freepascal.org/docs-html/user/userch9.html > . > . > > BTW, you may also want to have a look at > http://wiki.freepascal.org/Unit_categorization - it's incomplete (some > newer units are missing there), but it still

Re: [fpc-pascal] about dynamic array

2010-05-09 Thread spir
On Sun, 9 May 2010 16:58:49 +0200 José Mejuto wrote: > So finally we get a common point of view :) Sorry to have launched such an argument by starting a new thread "about dynamic array". My purpose, as a newcomer discovering the world of fpc, was just to get information I could not find myself

[fpc-pascal] class & object

2010-05-10 Thread spir
Hello, Below two quotes from the ref manual: http://www.freepascal.org/docs-html/ref/refch6.html#x67-750006 << In the Delphi approach to Object Oriented Programming, everything revolves around the concept of ’Classes’. A class can be seen as a pointer to an object, or a pointer to a record, wi

Re: [fpc-pascal] UTF8Decode -- string length

2010-05-11 Thread spir
On Tue, 11 May 2010 09:15:46 +0200 Graeme Geldenhuys wrote: > In that case the FPC documentation is wrong. Then could you correct the ref > documentation please - Section 3.2.5. As quoted below, the docs say > WideString is reference counted. > > > --[ FPC 2.4 language reference doc ]--

Re: [fpc-pascal] class & object

2010-05-11 Thread spir
On Tue, 11 May 2010 08:52:38 +0200 (CEST) Michael Van Canneyt wrote: > > > On Mon, 10 May 2010, spir ☣ wrote: > > > Hello, > > > > > > Below two quotes from the ref manual: > > [...] > > > > > > I'm rather confused whe

[fpc-pascal] a few trivial questions

2010-05-12 Thread spir
Hello, * TFPList Is there another way to traverse a list than for i :=0 to (list.count - 1) do ... What about list.high? Also, is it possible to set a list's base index to 1 (so that last_index=count)? There is a super handy forEachCall method (calling a proc for each item), but I cannot find

Re: [fpc-pascal] a few trivial questions

2010-05-12 Thread spir
On Wed, 12 May 2010 17:19:57 +0200 Graeme Geldenhuys wrote: > 2010/5/12 spir ☣: > > > > * TFPList > > Is there another way to traverse a list than > >    for i :=0 to (list.count - 1) do ... > > What about list.high? > > Yes, I use the Iterator design p

Re: [fpc-pascal] a few trivial questions

2010-05-12 Thread spir
On Wed, 12 May 2010 16:45:47 +0200 (CEST) Michael Van Canneyt wrote: > > > On Wed, 12 May 2010, spir ☣ wrote: > > > Hello, > > > > * TFPList > > Is there another way to traverse a list than > >for i :=0 to (list.count - 1) do ... > &g

Re: [fpc-pascal] a few trivial questions

2010-05-13 Thread spir
On Thu, 13 May 2010 09:33:12 +0200 Graeme Geldenhuys wrote: > spir ☣ het geskryf: > >>> Also, is it possible to set a list's base index to 1 (so that > >>> last_index=count)? > >> No. That would break all other existing code. > > > > I don&

Re: [fpc-pascal] a few trivial questions

2010-05-13 Thread spir
On Thu, 13 May 2010 18:24:28 +0300 Juha Manninen wrote: > Programmer count from 0 by nature. That's what separates programmers from > normal people. the programmer's naught gene ;-) Denis vit esse estrany ☣ spir.wikidot.com ___

[fpc-pascal] question about class

2010-05-14 Thread spir
Hello, I'm trying to transform a manually implemented type, with pseudo-method as funcs/procs, into an fpc "class" type; and facing numerous issue: namely 3 whole pages of compiler errors ;-). Are there somewhere more or less pedagogic examples of class code? *self* Do i need to explicitely nam

[fpc-pascal] timing again

2010-05-17 Thread spir
Hello, I posted a question about timing some time a go and got an answer; but let down for a while because other problems required my attention. So, I need a simple func to get the current time; mainly to benchmark various implementation choices, possibly for other needs. The timer module brin

[fpc-pascal] sentinels, "marks", enumerations

2010-05-19 Thread spir
[follow-up from the thread about "void"] To favor the use of custom sentinels, I'm thinking at a Mark type. This is not strictly necessary, since the user can build individual marks or series of them easily. Either as distinct referenced objects or as plain values (logical, number, string...).

[fpc-pascal] flexible record design

2010-05-28 Thread spir
Hello, I'm looking for a "convenient" way to implement a type for kinds of flexible records. "Best" means simple and efficient. A flexible record is a kind of set of name:value symbol, but completely modifyable at runtime. The necessary untyped aspect of the question is handled by values beeing

Re: [fpc-pascal] flexible record design

2010-05-28 Thread spir
On Fri, 28 May 2010 12:25:59 +0200 Felipe Monteiro de Carvalho wrote: > > I would like to know the underlying structure of TString (linked list, > > "flexible-ised" dynamic array, what else?). > > TStrings provides no storage. > > I think that TStringList should be what you are looking for.

Re: [fpc-pascal] flexible record design

2010-05-28 Thread spir
On Fri, 28 May 2010 16:03:28 +0200 (CEST) Michael Van Canneyt wrote: > TStrings provides an abstract interface. It allows you to associate an > object with each string in the list. > > This means you can do a > >L.Strings[i]:=Key; >L.Objects[i]:=MyObject; > > Or, in 1 statement: > >

[fpc-pascal] stuck with untyped pointer

2010-05-28 Thread spir
Hello, While waiting for more information about how to use "associated objects" with TStringList, I started to implement // lists for names (TString) and values (TFPList). This builds a kind of flexible record type, I called "Struct" because the name "Record" is not available ;-) Values are in

Re: [fpc-pascal] stuck with untyped pointer

2010-05-28 Thread spir
On Fri, 28 May 2010 20:51:10 +0300 Alberto Narduzzi wrote: > >i := self.names.indexOf(name); > >val := Struct(self.values[i]); > > raises "got untyped expected Struct". Sure, that's why I'm trying to > > cast... Without casting to Struct, the compiler indeed throws "got pointer > > expe

Re: [fpc-pascal] {SOLVED} stuck with untyped pointer

2010-05-28 Thread spir
Hello, It was a stupid naming issue: since I couldn't use "new", I had called the Struct constructor "struct" (found it logical, since it returns a struct). But because of case insensibility, I guess, when I wanted to cast back a pointer to Struct, the compiler denoted the constructor instead -

Re: [fpc-pascal] stuck with untyped pointer

2010-05-28 Thread spir
On Fri, 28 May 2010 23:07:35 +0200 José Mejuto wrote: > 3) Variable name "val" (Use Value instead, there is a function called > val). Naming problems in object pascal... I could not use "value" because it's the name of a method that returns a value, lol! So, I used "val". But now I cannot use

Re: [fpc-pascal] stuck with untyped pointer

2010-05-29 Thread spir
On Sat, 29 May 2010 00:33:00 +0200 José Mejuto wrote: > s> But the object layer brings the biggest issue with the implicit > s> "self" causing names external to a method to clash with local > s> names. > > Hmmm... I think that this should not happend. Is the case in your > posted example ? I

Re: [fpc-pascal] object model

2010-05-29 Thread spir
On Sat, 29 May 2010 01:09:50 +0300 Alberto Narduzzi wrote: > Hi, > > > Struct is declared as "class" so it inherits from TObject if not other > > class is especified. > > is that true? I don't mean not to trust you, but is the compiler > assuming that, or is it a FPC rule? IMO a class is a cla

[fpc-pascal] casting back a pointer to original type

2010-05-29 Thread spir
Hello, Say I store class instances of various types in a TFPList. All happen to be descendants of same superclass C and each one has a specific method "text". When retrieving and writing an element, if they were all direct instances of C, I would do something like: element := C(list[index])

Re: [fpc-pascal] casting back a pointer to original type

2010-05-29 Thread spir
On Sat, 29 May 2010 10:46:45 -0700 David Emerson wrote: > > element := C(list[index]); // casting back > > text := element.text; > > I cannot do that, even if elements all are *indirect* instances of C, > > because > > this calls C.text instead of the element's own proper text method.

Re: [fpc-pascal] {SOLVED} casting back a pointer to original type

2010-05-30 Thread spir
On Sat, 29 May 2010 16:54:44 -0700 Andrew Hall wrote: > On 29 May 10, at 15:26 , spir ☣ wrote: > > I cannot do that. C0 (and all classes) instances need a text method. I also > > cannot have 2 methods (one static, one virtual) with different names. It's > > a basic f

Re: [fpc-pascal] casting back a pointer to original type --> variable & value types

2010-05-30 Thread spir
This is a follow-up to the previous thread. Say I put in a TFPList elements of types C C1 C2, where C is a super-class. When I retrieve an element using var element : C; ... element := C(list[index]); text := element.text; ... what is the actual type of element? and of its value?

[fpc-pascal] power?

2010-05-30 Thread spir
Hello, // a & b are ints n := a ** b;// error: operator is not overloaded n := power(a,b);// error: identifier not found "power" Conversion to real does not help. How can I do? Denis vit esse estrany ☣ spir.wikidot.com __

[fpc-pascal] power?

2010-05-30 Thread spir
PS: is there a round(fractional_size) function? that's the reason why i needed power. Denis vit esse estrany ☣ spir.wikidot.com ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/ma

Re: [fpc-pascal] timing again

2010-05-30 Thread spir
On Tue, 18 May 2010 10:47:33 +0200 (CEST) "Tomas Hajny" wrote: > On Mon, May 17, 2010 22:25, spir ☣ wrote: > > > Hello Denis, > > > I posted a question about timing some time a go and got an answer; but let > > down for a while because other problems re

Re: [fpc-pascal] power?

2010-05-30 Thread spir
On Sun, 30 May 2010 18:28:47 +0200 Reimar Grabowski wrote: > On Sun, 30 May 2010 15:03:03 +0200 > spir ☣ wrote: > > > PS: is there a round(fractional_size) function? that's the reason why i > > needed power. > > http://community.freepascal.org:1/docs-html

[fpc-pascal] unit export control

2010-05-31 Thread spir
Hello, I'm converting a few components, first developped in independant programs, into units. I have 2 issues in the process. -1- internal dependency How can an interface element E0 depend on an implementation element E1? I cannot find a way to "forward-declare" E1, before E0, and have its act

[fpc-pascal] PChar & AnsiString

2010-06-01 Thread spir
Hello, The documentation in the ref manual about PChar may have i bit more details: http://www.freepascal.org/docs-html/ref/refsu13.html#x36-390003.2.7 Do the following statements hold true? * This type is mainly intended to interface with C code (or for low-level needs?). Else AnsiString shou

Re: [fpc-pascal] PChar & AnsiString

2010-06-01 Thread spir
On Tue, 1 Jun 2010 13:05:16 +0200 (CEST) Michael Van Canneyt wrote: [...] Thank you for all answers (all is now clear for me :-). > > * If a programmer explicitely assigns an existing string to a new variable, > > the intent is precisely copy-semantics, to make them independent for > > furthe

Re: [fpc-pascal] PChar & AnsiString

2010-06-01 Thread spir
On Tue, 01 Jun 2010 15:00:47 +0100 Martin wrote: > On 01/06/2010 11:23, spir ☣ wrote: > > What is the actual benefit of copy-on-write? I ask because of the following > > reasoning: > > * If a string is just used at several places, for example in output or into > > bi

Re: [fpc-pascal] PChar & AnsiString

2010-06-01 Thread spir
On Tue, 1 Jun 2010 14:36:36 +0200 Jonas Maebe wrote: > > On 01 Jun 2010, at 14:28, spir ☣ wrote: > > > On Tue, 1 Jun 2010 13:05:16 +0200 (CEST) > > Michael Van Canneyt wrote: > > > >> This is not correct. Many strings are simply referenced several &g