Re: [fpc-pascal] How are Assigned, Free, Nil and Destroy related?

2011-10-21 Thread Alexander Shishkin
22.10.2011 10:20, Felipe Monteiro de Carvalho пишет: I understand Assigned as being the same as<> nil, so Assigned(Object) = Object<> nil I vaguely remember that it could be safer in some corner case, but I don't remember ever meting that. Method pointers? __

Re: [fpc-pascal] How are Assigned, Free, Nil and Destroy related?

2011-10-21 Thread Felipe Monteiro de Carvalho
I understand Assigned as being the same as <> nil, so Assigned(Object) = Object <> nil I vaguely remember that it could be safer in some corner case, but I don't remember ever meting that. Free is how you release the memory allocated for a object. Free calls Destroy. Never call Destroy manually.

[fpc-pascal] Re: How are Assigned, Free, Nil and Destroy related?

2011-10-21 Thread Frank Church
On 21 October 2011 18:19, Frank Church wrote: > > This is one question I have wanted to ask for a long time. > > How are Assigned, Free, Nil and Destroy related, and when is one or another > appropriate? What other procedure have I missed? > > There are so many articles and mailing list threads o

Re: [fpc-pascal] Delphi's anonymous functions in Free Pascal

2011-10-21 Thread Gregory M. Turner
- Original Message - > 18.10.2011 0:53, Andrew Pennebaker пишет: > > Does Free Pascal have anonymous functions that you can pass around, > > e.g. > > to a sort(compare : function, arr : array) function? > > > > anonymous functions = closures = lambdas are part of functional > paradigm. obje

Re: [fpc-pascal] Re: Delphi's anonymous functions in Free Pascal

2011-10-21 Thread Marco van de Voort
The link below describes two uses for anonymous methods. http://stackoverflow.com/questions/7818759/delphi-anonymus-methods-pro-and-cons-good-practices-when-using-closuresanony/7821882#comment9576663_7821882 I don't entirely subscribe to the (1) one, it seems to be mostly a shorthand argument.

Re: [fpc-pascal] Re: Delphi's anonymous functions in Free Pascal

2011-10-21 Thread Jürgen Hestermann
Juha Manninen schrieb: > Please look at some old Pascal code from 80's. Lots of shortstring manipulation with pointers. Very much comparable to C, and as prone to errors as C. Yes, new string types were needed. But why not doing it right in one step? Instead we now have lots of different stri

[fpc-pascal] How are Assigned, Free, Nil and Destroy related?

2011-10-21 Thread Frank Church
This is one question I have wanted to ask for a long time. How are Assigned, Free, Nil and Destroy related, and when is one or another appropriate? What other procedure have I missed? There are so many articles and mailing list threads on this issue that I don't think asking it makes me sound lik

Re: [fpc-pascal] Delphi's anonymous functions in Free Pascal

2011-10-21 Thread Alexander Shishkin
18.10.2011 0:53, Andrew Pennebaker пишет: Does Free Pascal have anonymous functions that you can pass around, e.g. to a sort(compare : function, arr : array) function? anonymous functions = closures = lambdas are part of functional paradigm. object pascal itself is not functional language. Bu

Re: RE : [fpc-pascal] sqldb how to find a record fast with primary key

2011-10-21 Thread Michael Van Canneyt
On Fri, 21 Oct 2011, Felipe Monteiro de Carvalho wrote: On Fri, Oct 21, 2011 at 5:22 PM, Ludo Brands wrote: You can use indices and locate with TSQLQuery as follows:  SQLQuery1.AddIndex('idx_no_art','no_art',[]);  SQLQuery1.IndexName:='idx_no_art';  SQLQuery1.Open;  ...  SQLQuery1.Locate('no

RE : [fpc-pascal] sqldb how to find a record fast with primary key

2011-10-21 Thread Ludo Brands
> Can't you do the lookup in the DB server by a SQL join for example? > Or, if you need do some processing in between, use 2 queries and build the "where" clause for the 2nd from the results of the 1st. If you don't need the full table, don't use select *. Ludo

Re: [fpc-pascal] sqldb how to find a record fast with primary key

2011-10-21 Thread Martin Schreiber
On Friday 21 October 2011 17.41:56 Felipe Monteiro de Carvalho wrote: > I get the value of the primary key of the table from the request, so I > though that because it is the primary key I would be able to quickly > jump to it. But it seams that not? From what I understood the > solutions are first

Re: RE : [fpc-pascal] sqldb how to find a record fast with primary key

2011-10-21 Thread Felipe Monteiro de Carvalho
On Fri, Oct 21, 2011 at 5:22 PM, Ludo Brands wrote: > You can use indices and locate with TSQLQuery as follows: >  SQLQuery1.AddIndex('idx_no_art','no_art',[]); >  SQLQuery1.IndexName:='idx_no_art'; >  SQLQuery1.Open; >  ... >  SQLQuery1.Locate('no_art','200295',[]); Thanks, that's really interre

[fpc-pascal] Re: Delphi's anonymous functions in Free Pascal

2011-10-21 Thread leledumbo
> Maybe anonymous methods were introduced in other languages because they didn't have something like OP's procedure variables IMO, it's because they're lazy to declare things before they use it. Often, an anonymous function which first used just once eventually used more than once. When that hap

RE : [fpc-pascal] sqldb how to find a record fast with primary key

2011-10-21 Thread Ludo Brands
> > > > No sqldb specific answers on this one? I did some googling and also > > searched for TPrimaryKey or LocalIndex in sqldb without > results ... =( > > To my knowledge there is no fast search/locate in sqldb. > Maybe we should have a look at Martin Schreibers' implementation. > > Michael.

Re: [fpc-pascal] sqldb how to find a record fast with primary key

2011-10-21 Thread Martin Schreiber
On Friday 21 October 2011 16.50:32 Felipe Monteiro de Carvalho wrote: > On Fri, Oct 21, 2011 at 4:50 PM, Martin Schreiber wrote: > > Most code is in lib/common/db/msebufdataset.pas. Lookup buffers are in > > lib/common/db/mselookupbuffer.pas. Heavy stuff. ;-) > > How much from the other stuff wo

Re: [fpc-pascal] sqldb how to find a record fast with primary key

2011-10-21 Thread michael . vancanneyt
On Fri, 21 Oct 2011, Martin Schreiber wrote: On Friday 21 October 2011 16.30:18 michael.vancann...@wisa.be wrote: On Fri, 21 Oct 2011, Felipe Monteiro de Carvalho wrote: Ping, No sqldb specific answers on this one? I did some googling and also searched for TPrimaryKey or LocalIndex in sqldb

Re: [fpc-pascal] sqldb how to find a record fast with primary key

2011-10-21 Thread Felipe Monteiro de Carvalho
On Fri, Oct 21, 2011 at 4:50 PM, Martin Schreiber wrote: > Most code is in lib/common/db/msebufdataset.pas. Lookup buffers are in > lib/common/db/mselookupbuffer.pas. Heavy stuff. ;-) How much from the other stuff would I need to compile your DB modules? Any beginner guides to stablish a connect

Re: [fpc-pascal] How can I implement "thrice" in Free Pascal?

2011-10-21 Thread Sven Barth
Am 20.10.2011 17:08, schrieb Andrew Pennebaker: 2.6, eh? Awesome. I'm using the SVN trunk, but it's not working for me for some reason. I'll just wait for v2.6 then. Didn't you just say that you're using 2.4.4? Trunk is currently 2.7.1. Regards, Sven _

Re: [fpc-pascal] sqldb how to find a record fast with primary key

2011-10-21 Thread Martin Schreiber
On Friday 21 October 2011 16.30:18 michael.vancann...@wisa.be wrote: > On Fri, 21 Oct 2011, Felipe Monteiro de Carvalho wrote: > > Ping, > > > > No sqldb specific answers on this one? I did some googling and also > > searched for TPrimaryKey or LocalIndex in sqldb without results ... =( > > To my

Re: [fpc-pascal] sqldb how to find a record fast with primary key

2011-10-21 Thread michael . vancanneyt
On Fri, 21 Oct 2011, Felipe Monteiro de Carvalho wrote: Ping, No sqldb specific answers on this one? I did some googling and also searched for TPrimaryKey or LocalIndex in sqldb without results ... =( To my knowledge there is no fast search/locate in sqldb. Maybe we should have a look at Ma

Re: [fpc-pascal] sqldb how to find a record fast with primary key

2011-10-21 Thread Felipe Monteiro de Carvalho
Ping, No sqldb specific answers on this one? I did some googling and also searched for TPrimaryKey or LocalIndex in sqldb without results ... =( thanks, -- Felipe Monteiro de Carvalho ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://l

Re: [fpc-pascal] Why do string indices start at 1, but array indices start at 0?

2011-10-21 Thread Marco van de Voort
In our previous episode, Jonas Maebe said: > > During compilation, by statically checking the indices used to access the > > string, the compiler could fire a warning (or error?) if a string[0] is > > found. > > The compiler already does that (except for shortstrings, where string[0] is > valid)

Re: [fpc-pascal] Why do string indices start at 1, but array indices start at 0?

2011-10-21 Thread Jonas Maebe
On 21 Oct 2011, at 08:25, Roberto P. wrote: > During compilation, by statically checking the indices used to access the > string, the compiler could fire a warning (or error?) if a string[0] is > found. The compiler already does that (except for shortstrings, where string[0] is valid). Jonas

Re: [fpc-pascal] Re: Delphi's anonymous functions in Free Pascal

2011-10-21 Thread Graeme Geldenhuys
On 2011-10-20 22:55, Florian Klämpfl wrote: > > The same can be done with fpc (nested if needed) procedure variables and > it will be more readable (imo)? The example still does not take This seldom happens, but here I fully agree with Florian. ;-) Every example of anonymous methods I have seen

Re: [fpc-pascal] How can I implement "thrice" in Free Pascal?

2011-10-21 Thread Graeme Geldenhuys
On 2011-10-20 17:08, Andrew Pennebaker wrote: > I'll just wait for v2.6 then. No need to wait, checkout the fixes_2_6 branch, which is currently at version 2.5.1, but will become the v2.6.0 release. This also means you will help test the future 2.6.0 release and catch any possible bugs _before_ th