Re: [fpc-pascal] using exceptions

2012-01-03 Thread Lars
Marcos Douglas wrote:
> On Thu, Dec 22, 2011 at 4:17 PM, Anton Shepelev 
> wrote:
>> Marcos Douglas:
>>
>>> It's  not  difficult,  but is boring have always a
>>> parameter or function return to return  an  error,
>>> and  have  to  verify  if error then... if not er-
>>> ror...  if error and error then... etc
>>

But it is just as boring to write code where you have to check all the
exceptions.  Often I see people using StrToInt without checking that it
was a success.  TryStrToInt allows you to avoid exceptions, so if
exceptions are so good, why do people use trystrtoint and why did borland
create it if delphi is supposed to handle things the exception way? I
think sometimes checking for errors makes the code easier to direct..
except forces you to put the code as if you are using a GOTO except label.

>
> No, I mean is better use try-except than nested IFs/GOTO/etc.

Exceptions are actually GOTO labels.. if you think about what is
happening. If there are any exceptions what happens in your code? You GOTO
the exception area.


>
> Thanks for the tips... but, IMHO, the code above would be more simpler
> like that:
>
> begin
> Result := False; // Success flag
> [...]
> procOne;
> procTwo;
> procThree;
> [...]
> Result := True;
>   except
>  on e: Exception do
>ShowMessage(e.Message);
>   end;
> end;
>
> Marcos Douglas


But that just a goto statement going to the except label.. Exceptions in a
way are actually forcing you to write your code in  a GOTO way.

Often you want to handle errors differently, your above code sends it all
to the GOTO except area.. but what if you have to clean up things
depending on the situation? free memory, etc. It's often never as simple
as going to the exception area. It seems easier on the surface to use
exceptions, but when you look into it, it's often not as simple as writing
all code to GOTO exception area...

Is the above code an exception or an error that you are catching? are
errors and exceptions the same thing? Once again, IMO this whole subject
needs to be researched more (academically too). What is the difference,
precisely and rigorously, between an error and exception?  Are exceptions
errors?  If so, why do some people say only to throw an exception when it
is an exception, and use errors for other cases? If that is the case,
exceptions cannot be the same as errors.

In Java exceptions and errors are the same thing, and/or the water is
muddy and it is not clearly defined. In Delphi the water is muddy.  Often
I see people using TryStrToInt instead of StrToInt, which means that
people actually prefer checking the error (false or true) instead of
checking the exception.

Another interesting article is:
http://www.joelonsoftware.com/items/2003/10/13.html


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


Re: [fpc-pascal] Advanced Records - Why not available by default?

2012-01-14 Thread Lars
Daniel Gaspary wrote:
> Any special reason to Advanced Records be available only in Delphi Mode ?


Personally, I'm getting sick of all the new features added to delphi that
don't add anything meaningful, and just add complexity to the compiler.
why didn't borland just make people use old borland objects with methods
instead of new advanced records? Old borland objects are advanced
records..

Ticking me off more: why do we even have objects and classes? what is an
object? what are classes?  I would have preferred if borland would have
just called old borland objects "Extended records" from day one. Now we
have this feature overload in the language and it's becoming more and more
complex of a language (needlessly). Objects, Classes, records.. aren't
they all the same thing? I don't even personally buy the idea that objects
even exist.. i think they are just extended records. What is an object? an
instance of a class? if so, why did borland call the type definition
"object" if it was supposed to be a class? Ugh. Ugly language - it is
becoming - sorry to say!
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] libQT4Pas - Why it is needed?

2012-01-29 Thread Lars
Do other languages like python use the plain c interface, or C++?

how about something like ruby, lua, objective C, php ..



Krzysztof wrote:
> Just as I thought - it is object class thing. So if "FPC does not
> (fully) support directly calling external C++ libraries" there are
> plans to support it? This will be great
>
> 2012/1/29 Michael Van Canneyt :
>>
>>
>> On Sun, 29 Jan 2012, Krzysztof wrote:
>>
>>> Hi,
>>>
>>> I am wondering. If I build application for linux using gtk2 widgetset
>>> for GNOME (or XFCE etc.) and send this program to my friend, then he
>>> can run it without any external librarys (of course if he have gnome
>>> too), this same thing on windows. But why when I build application on
>>> KDE interface I need some external libQT4Pas to run it and my friend
>>> need it too (he have KDE so all QT librarys too)? There is no
>>> libGTK4Pas so why exists layer libQT4Pas? What is difference between
>>> GTK and QT librarys?
>>
>>
>> GTK has a procedural C interface, it is exposed in the GTK libraries.
>> The
>> FPC compiler understands this interface.
>>
>> Qt is written in C++, and exposes C++ classes in the Qt libraries. The
>> FPC
>> compiler does not know how to handle C++ classes.
>> Therefor, a 'procedural' interface to the C++ needs to be made, and this
>> is
>> libQT4Pas. It is generated by a GCC.
>>
>> Michael.
>>
>> ___
>> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
>> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>>
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>

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


Re: [fpc-pascal] I found FPC v0.2 source code :-)

2012-01-29 Thread Lars
Anything that has Capacitors in it which use wet electrolytic, can dry out
with age. Old stereos that crackle when you turn up the volume are an
example.  In motherboards though it seems it's more a problem that
capacitors blow up and bulge out which is probably from usage rather than
idle age.


Graeme Geldenhuys wrote:
> On 29 January 2012 16:21, Mark Morgan Lloyd
>  wrote:
>>
>> My experience is that both media and drives suffer with age, even if not
>> being used.
>
> I can imagine that might be for the disk, but not the drive itself. I
> recently cleaned up my garage and found a crate full of old hardware
> (boxes and boxes of 5.25" and 3.5" floppies, 2 5.25" floppy drives,
> 286 motherboard, 1x 84MB HDD, very old software and games etc...). The
> floppy drives and diskettes still worked. :-)
>
> No idea what I must do with all this old stuff though Does anybody
> collect such stuff?
>
> @Florian
> Definitely try to preserve such old software releases. If you can, you
> should upload it to SourceForge.

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


Re: [fpc-pascal] I found FPC v0.2 source code :-)

2012-01-30 Thread Lars
waldo kitty wrote:
> On 1/29/2012 17:41, Lars wrote:
>> Anything that has Capacitors in it which use wet electrolytic, can dry
>> out
>> with age. Old stereos that crackle when you turn up the volume are an
>> example.  In motherboards though it seems it's more a problem that
>> capacitors blow up and bulge out which is probably from usage rather
>> than
>> idle age.
>
> speaking as a hardware man, these components are easily replaced... in
> many
> cases, if the board's traces are damaged, they, too, can be repaired... i
> am
> still replacing capacitors on boards from that old problem where
> capacitors were
> purchased from manufacturers that fell to the capacitor espionage
> situation of
> some, what?, 15 years ago?
>

I have replaced capacitors too, on car electronics and stereos, with great
success.  Even you can get better capacitors that don't dry out.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] libQT4Pas - Why it is needed?

2012-01-30 Thread Lars
waldo kitty wrote:
> On 1/29/2012 17:38, Lars wrote:
>> Do other languages like python use the plain c interface, or C++?
>>
>> how about something like ruby, lua, objective C, php ..
>
>
> :( i don't nderstand why one would want to apply interpreted script
> languages,
> al la BASIC, to today's tasks... sure, these are neat and "more modern"
> but they
> are still interpreted scripting languages :(
>

Eh, I meant how does ruby, lua, objective c, and similar tools bind the
C++ api. Do they use an automatic tool that converts QT C++ objects to
procedural? or by hand, someone converts the objects to procedures and
structs? Or do they use the c++ objects directly to python objects..


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


Re: [fpc-pascal] libQT4Pas - Why it is needed?

2012-01-30 Thread Lars
Felipe Monteiro de Carvalho wrote:
> On Sun, Jan 29, 2012 at 11:38 PM, Lars  wrote:
>> Do other languages like python use the plain c interface, or C++?
>>
>> how about something like ruby, lua, objective C, php ..
>
> No idea, but Python, ruby, lua and php do not generate real programs
> but instead are just scripts which run in a interpreter, which is
> immensely different from a real program.

"Real Programmers"...

When you use pascal to build web programs you use templates, right.. so
you are interpreting templates. When you read an INI file you are
interpreting the INI file. Some pascals, safe ones, are interpreted. Like
Oberon, or  UCSD Pascal. When you parse an Edit.Text and check it to make
sure there is not some user error on input, you are interpreting things.
Compiled programs are not fully compiled, they always contain some run
time interpretation.  When you use regexes they are interpreted. When you
use wildcards in search boxes they are interpreted.  From my testing, CGI
programs that are compiled binaries, are actually SlowER than PHP
programs. I am no fan of PHP , but it is pretty fast.


>
> A more close comparison to Pascal might be asking what Fortran, Cobol,
> Ada or other similar compiled languages do, and I think that all of
> those would need a C interface.
>

True, but still interesting to know if Python objects are somehow
compatible with C++ objects, as a kind of academic exersise.. how do they
do it? Possibly they just bind to procedural API, but it would be cool if
they somehow did it more effectively.  I also mentioned Objective C in my
request but I have no idea if objective c even has a QT binding..

> I know very well Java due to Android work, which cannot bind to
> anything directly. It requires a special format using plain procedures
> in a special way, so it is like a C interface, or a plan Pascal
> procedural interface. It is called JNI and it will never accept C++
>

That's good information and adds to the knowledge.. of how they do it. Cool.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] I found FPC v0.2 source code :-)

2012-01-30 Thread Lars
Graeme Geldenhuys wrote:
> On 30 January 2012 10:54, Mark Morgan Lloyd  wrote:
>>
>> People who repair things are a dying breed.
>
> I fully agree.  Totally off-topic, but anybody here know of a course
> or books one could buy on basic electronic repairs. Thinking in lines
> of PSU etc to start with. I've been long wanting to enter this as a
> hobby project of mine, but I have no idea where to start. I am so
> stick of buying new PSU or other power adapters, when there is
> probably a good chance it could have be repaired in a few minutes
> (only if I knew how).


Some power supplies that I have found faulty before have a blown glass
fuse in them. Sometimes it is not worth repairing things because there is
risk of electrocuting yourself.. other times it is worth repairing.
Depends. I don't know of any books but people used to start off with 555
timers and read books on them. I found it too boring building clocks and
other trivial devices and I was happy to learn programming which is easier
to do complex things than soldering (which was extremely difficult).

To keep it on topic, there is programmable hardware available where you
can change the hardware using a hardware programming language. Niklaus
Wirth is interested in such technology. Instead of soldering in capacitors
and resistors, you program in something that emulates a resistor or
capacitor. This makes prototyping circuits much easier because instead of
soldering, you program in the devices you would have otherwise soldered.
The devices are called Field-programmable gate array's I think, and from
what I remember Niklaus Wirth was programming a remote control helicopter
with it, or maybe oberon, it's been so long that I cannot remember the
details. Just trying to keep it a bit on topic.

>
> I remember 8 years ago, my laptop charger had a worn wire. You had to
> wiggle the wire before the laptop would charge. I search high and low
> in the UK for somebody that could simply replace the cable. Nobody
> wanted to touch it! Eventually I bought a soldering iron, cut out the
> broken part of the wire and fixed it myself. It's ridiculous that
> nobody wants to repair things any more.
>
>

I've had these experiences too, sometimes the power supply is 50 bucks. If
the power supply is only 12 dollars then it's better just to replace it
since time equals money.  But not always, it depends.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] TStringStream.DataString returns garbage?

2012-02-01 Thread Lars
Graeme Geldenhuys wrote:
> On 2 February 2012 00:14, Michael Van Canneyt  wrote:
>>
>> Ehm.. this should be S[1], now you're writing the pointer.
>
>
> Thank you. That's what happens if you have too many very late nights
> programming - sleep deprivation catches up and one overlooks the
> simple mistakes.
>
>
>

It's actually a common mistake. Also @s vs "s", and @s[1], it can be
confusing.

It's one thing I don't like about unsafe languages, pointers, and such
stuff. It's as if we are programming in advanced C, or C++. Common,
pointer mistakes? this is C? Really? Can't we make it safer? LOL.

What could be done to make this safer? I don't know. What does java do in
a situation like this? Could we learn from it?

If somehow the compiler could statically check that only s[1] is allowed, 
and not S, that would be good.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] TStringStream.DataString returns garbage?

2012-02-02 Thread Lars
Jorge Aldo G. de F. Junior wrote:
> I would vote for a new function on all stream types to allow writing
> strings in the expected way. Everybody hits that problem once.

I think there is  a class.WriteString function instead of class.Write()

Similar to a DEPRECATED; directive, there could be an UNSAFE; directive
warning the user that he is using untyped pointer or something.

Problem is that adding more things like this to the langage make the
compiler more complex.

In oberon there is a way to mark a module UNSAFE if you are linking to C
code and such.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] TStringStream.DataString returns garbage?

2012-02-04 Thread Lars
it seems

http://docwiki.embarcadero.com/VCL/XE2/en/Classes.TStringStream.WriteString

in delphi the WriteString() function accepts a strongly typed string.

This might be a compatibility problem in delphi mode since in fpc,
writestring accepts a untyped pointer if i am not mistaken.

Different behaviors, right? A strongly typed string parameter wouldn't
send in the length of the string AFAIK, it would just send the string
contents.

so if someone was porting code from delphi, wouldn't this produce
different behavior in fpc?
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] TStringStream.DataString returns garbage?

2012-02-04 Thread Lars
Lars wrote:
> it seems
>
> http://docwiki.embarcadero.com/VCL/XE2/en/Classes.TStringStream.WriteString
>
> in delphi the WriteString() function accepts a strongly typed string.
>
> This might be a compatibility problem in delphi mode since in fpc,
> writestring accepts a untyped pointer if i am not mistaken.

Actually I think there is just a problem with the FPDOC system:

http://www.freepascal.org/docs-html/rtl/classes/tstringstream.writestring.html

Says:

public procedure TStringStream.WriteString(
  const AString:
);

I thought const AString was untyped due to that doc page, not the fpc
sources.

Shouldn't the docs generate a page that says:

const astring: string;

i.e.

public procedure TStringStream.WriteString(
  const AString: string
);



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


Re: [fpc-pascal] Re: What is the most widely used Pascal on Linux and other Unix variants?

2012-02-27 Thread Lars
Frank Church wrote:
> 5. This requires an increase in the uptake of Pascal. I mean if a language
> like D can get so much attention and have libraries being created for it
> why can't Pascal which has been longer established.
>

Another language to check out is TutorialD by Date and Darwen, a pascal
like relational database language. Another interesting one which there is
almost no information about is "Pascal/R" which was a relational pascal
that died quickly, but I don't know why.


> 6.  I guess one major shortcoming of Pascal is it is not immediately
> identified with objects, like C. Can Free Pascal simply change its name to
> Object Pascal

Not all of freepascal is object oriented, a lot of it is simple procedural
and you have the option to use objects if you want. Java and Ruby make the
grand mistake of making everything an object and forcing you to code in
objects when you shouldn't have to. C# the ugly java rip off language also
forces you into objects and classes.  If IntToStr was welded in to some
object and I had to create an "IntToStr object" before calling IntToStr,
that would suck major.

What would be nice is some actual innovation in programming languages
instead of reinventing C++ over and over again.  I think what languages
need is a relational twist to them. A new data type known as the Table in
our langauges instead of arrays and records. It is known as a Relvar in
TutorialD. We use ugly "object relational (o/r) mappers" instead of having
tables and relvars in our language. Too many people reinvent the database
using arrays, associative arrays, stringlists, TLists - all this should be
a database table that you can create easily in your language instead of
resorting to embedding SQL strings into your program.

> Honestly I think the name is probably the biggest problem if in an era of
> objects everything it is not associated with Pascal due to its age and
> past.
>

Objects everything.. yuck.. I still like simple procedural code for
teaching people and for doing quick prototypes, I think one of the biggest
mistakes of the industry is obsession with objects and not enough
education about relational techniques (http://www.dbdebunk.com)
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] fpweb and security

2012-02-27 Thread Lars
michael.vancann...@wisa.be wrote:
>
>
> On Mon, 27 Feb 2012, ik wrote:
>
>> Hello,
>>
>> I'm thinking now to use fpweb for a web application I need to build,
>> but the application is going to be over the internet, and I'm
>> interesting in knowing about few security issues that are supported or
>> not.
>>
>> Does it have any CSRF protection ?
>> What other if any security tools does it have ?
>>
>
> None. It is a HTTP handling framework. Other than Basic Authentication on
> the web server level, HTTP does not offer security mechanisms, and
> therefor
> none are implemented in FPweb either.


HTTP doesn't really address security, but a web framework can provide some
security, such as SQL escaping to prevent sql injection, along with URL
escaping to prevent URL injection through url variables. Using SQL
prepared statements instead of regular sql queries should help, but I've
heard that even SQL prepared statements can be injected.

CSRF protection.. that's a good question.. this guy has an interesting
article and blog comments on it:
http://www.codinghorror.com/blog/2008/10/preventing-csrf-and-xsrf-attacks.html


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


[fpc-pascal] with no if assigned() there are bugs

2016-09-20 Thread Lars
Hi all, I am wondering what your thoughts are on this idea: add the
ability to do if assigned() on all objects to prevent bugs, maybe as a
compiler feature. Before you write me off as just another person
requesting yet another silly feature (it may in fact be that), here is the
problem:

A lot of "other people's code" I deal with, has access violations. When I
try to debug the application code, I waste hours of my time, only to find
out that it was that common bug: a person forgot to check

  if assigned(SomeObject)

before accessing the object properties or fields.  i.e. the access
violation was because of referencing an invalid (non existing) object.

So what if the compiler had an option to check if assigned, before
accessing any object. This would seem to be like a performance hit however
I'm not sure that an If check is that much of a waste of CPU power. It
would be similar to range checking: yes, may be a performance hit, but
increases safety of application.

If you downloaded some code and had an access violation, the first thing
you would do is enable the compiler option to always if assigned() check
automatically on all objects, recompile the app, and if the bug goes away
you know it was because !someone! forgot to check "if assigned()" on an
object before accessing it.

Would this be a good safety feature, in the spirit of range checks, and in
the spirit of avoiding C like code (buffer over runs) because essentially
this is unsafe C like programming to access a dead object, IMO.

With garbage collection you don't have this problem (maybe it creates
other issues such as reusing objects you didn't really want to use). 
However as FPC and Delphi are likely not going to be garbage collected for
some time, if ever, wouldn't this If Assigned check add one more reason to
use FPC without the nasty access violations caused by non garbage
collected programming?

I am open to being debated on this: I'm not 100 percent certain this
feature would be as good as I make it out to be. Would it be hard to
implement? I don't know.. an if check, automatically, before accessing an
object   Then also would you do performance optimizations to only call
if assigned() once if a bunch of object fields are being accessed in a row
such as:

stringlist.add('one')
stringlist.add('two')

Only one if assigned() check is needed before the above two calls, not a
check each time stringlist.add is called. This performance optimization
could be a worry later, and the first time if assigned() is implemented
automatically by the compiler, performance is ignored.  Plus this feature
might just be a debug facility rather than something you enable when you
ship the application similar to range checking (although some would
argue range checking should ALWAYS be on and turning it off is silly).

What are your thoughts? Thing is, I've come across more than my fingers
can count, of times that this bug has bit me, especially when I am
downloading someone elses' code and haven't gone through thousands of
source files looking to see that if assigned() was called.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] with no if assigned() there are bugs

2016-09-21 Thread Lars

> On 2016-09-21 13:27, Pierre Free Pascal wrote:
>
> There is also the -gc option:
> -gcGenerate checks for pointers
>


I was going to add to my original post "sorry if this feature already
exists, or something similar".

Now I have to see what Delphi offers, as I use fpc and delphi and need
this check on both systems!


p.s. unrelated off topic: someone said that Delphi Berlin Starter only
works on Windows 10. I found it worked fine on my Windows 7, FYI.  But I
think the free offer (download) is over, or if not, shortly.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] with no if assigned() there are bugs

2016-09-21 Thread Lars
On Wed, September 21, 2016 6:27 am, Pierre Free Pascal wrote:
> There is also the -gc option:
> -gcGenerate checks for pointers
>
>
> This is another debugging option, that is not used very often,


I could not find this option in the Lazarus options under debugging or any
other tab... maybe it is not used often enough that Lazarus missed putting
it in a compiler option configuration... or I may have missed it.

I think this is a good check to have So in Lazarus must I make my own
custom option, or is it hidden somewhere where I cannot see it?

I should post this to lazarus list: in this case do I double post to both
freepascal list and lazarus list, or better to just post a message to one
list?

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


Re: [fpc-pascal] corba interfaces - is/as not working properly

2016-09-28 Thread Lars
On Wed, September 28, 2016 2:24 am, Graeme Geldenhuys wrote:
> On 2016-09-28 08:38, David Emerson wrote:
>
>> I'm testing out CORBA interfaces before changing all my code to use
>> them (I would prefer not to have managed types for interfaces).
>>
>
> I've been using CORBA style interfaces for years,


Curious, where do corba interfaces come in handy ? When can you use them
that object oriented code won't offer the same features? I'm wondering if
maybe GoLang interfaces are so popular because of similar reasons to the
heavily underused and infamous interfaces available in delphi/fpc for
years.

i.e. what's the basic point of using an interface compared to objects and
inheritance and procedures? Where do they really shine?

In goLang (don't mean to make this off topic) interfaces are very similar
to VarArgs or Variants but not as evil. I mean to keep this on topic by
asking specifically what corba interfaces should be used for?  Also do
they work across DLL's or DSO's sort of like microsoft COM?
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] corba interfaces - is/as not working properly

2016-09-28 Thread Lars
On Wed, September 28, 2016 3:44 pm, Graeme Geldenhuys wrote:

> Others like the fact that COM Interfaces are reference counted - they
> sometimes come in handy, but do tend to complicate matters much more.
>


And Corba interfaces.. you have to implement that yourself?

I found this
http://www.lenholgate.com/blog/2001/02/corba---reference-counting.html

As for googling the info, sometimes I just find it easier to talk to a
real programmer with experience than sifting through millions of pages of
misinformation from google :-)
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] Piping: high level tool? Strong types sent via pipe

2016-10-17 Thread Lars
I was thinking: pipes are useful to communicate between processes. How
about a high level communication system instead of just sending low level
strings over the pipe? For example strong typing. If you want to send an
integer over a pipe, you generally have to parse the string and ensure it
is a number being sent over the pipe and not text, etc. So instead of
everyone reinventing their own strong typing system over pipes to ensure
data is received correctly, why not have a pipe library that anyone can
use which sends strongly typed information over the pipe?

i.e. Pipe.SendInteger, Pipe.SendString,

Instead of just

writeln(pipe, 'a string') which will need to be parsed and checked.

This may be something like interprocess communication library that is
already available for FPC, I don't know. I just had a brainstorm here...
pipes remind me of sockets...if you send data over a socket you have to
parse it, deal with it... Everyone reinvents their own messaging system
instead of having a single high level tool that everyone uses.

Also nice would be:

Pipe.Send(varargs)

i.e.

Pipe.Send(integer, string, byte, anythingyouwant).

Am I just reinventing the library already available for fpc for IPC
(interprocess communication) ?

Last time I tried it (been a long time) I had some issues with duplicates
showing up when communicating over IPC.

Anyway so what I would like to do, is have one process open up a pipe, and
send strongly typed data to another process. This is almost as powerful as
having a DLL since a dll allows you to communicate code between a dll and
an exe.. But with pipes no DLL is required, just two exes. This is
extremely powerful underused mechanism to create exe or elf plugins that
communicate with a main exe/elf program.

I don't like low level piping and sockets where you have to parse data and
create your own message system: everyone reinvents the wheel instead of
having a single library to use that is high level. I think sockets
communication and pipes are the biggest case of everyone reinventing the
wheel that there is!
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Generic way to pre-maturely exit TCustomApplication without memory leaks

2016-10-21 Thread Lars
On Mon, October 17, 2016 12:18 am, grouchysmurf wrote:
> Hi.
>
>
>>> I ended up doing exactly that though it feels like an ugly thoug[h]
>>> incomplete hack. Thanks for the tip.
>
>> Why a hack?
>> System.ExitCode is meant for returning exitcodes.
>>
>
> Being  forced to forfeit one or two layers of abstraction in an object
> oriented environment does sound like a hack to me. A direct access to
> system variables is inelegant to my unexperienced eye but YMMV.
>

Wasn't MSEIDE by Martin dealing with exit codes in a different way? been a
logn time since I used it but I recalled something about exit codes in it.
If it is an OOP architecture (msegui) how does he deal with it? Sorry this
is a little off topic but, different tools deal with things in different
ways and sometimes it is nice to learn from the neighboring tool to see
what elegant solutions they came up with.


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


Re: [fpc-pascal] C translation question

2016-10-23 Thread Lars
On Sat, October 22, 2016 4:44 am, José Mejuto wrote:
> Hello,
>
>
> It is at the end of the loop for sure, it points to the "previous" point
> in the polygon and in the case of the first testing point the "previous"
> one is the last one.
>
> So the correct code is:
>
>
> j := i;
>
> This is my automated C code conversion for that function:

..

Hi, what is the status of automated conversion tools? Last I remember
reading about them was when I read a delphi page on how to convert header
files. Are you saying that nowadways you can actually convert plain C code
to fpc, not just header files but all C code? Just certain types of C
code?  Are there any competing tools or everyone uses just one main tool?

Thanks! Interested
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] C translation question

2016-10-23 Thread Lars
On Sun, October 23, 2016 2:31 pm, Bernd Oppolzer wrote
> But if you translate the C for loop to a while loop first,

Agree! For loops, are not nearly as flexible and powerful as while loops.
For loops can get you stuck in a certain mode of thinking and you try to
develop hacks to manipulate the for loop to do what you want to do, when
in fact just using a while loop with more custom control is the way to go.

I love for loops for their simplicity, but difficult problems cannot be
solved via for loops.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] C translation question

2016-10-24 Thread Lars
On Mon, October 24, 2016 8:00 pm, Lars wrote:
> I previously wrote:
>
>>
>>> Are you saying that nowadways you can actually convert
>>> plain C code to fpc,
>
> Found this too:
>
>
> http://c2pas.sourceforge.net/
>


And there is also this interesting find:

http://cc.embarcadero.com/item/26951

(C to Pascal Converter 2.1.7.2015)

Looks as though there are multiple efforts, too bad these people didn't
combine forces and create a github account and work together on these
tools.

There is also this:
http://www.astonshell.com/freeware/c2pas32/


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


Re: [fpc-pascal] C translation question

2016-10-24 Thread Lars
I previously wrote:
>
>> Are you saying that nowadways you can actually convert
>> plain C code to fpc,

Found this too:

http://c2pas.sourceforge.net/

It says it can convert a large portion, but not all, obviously
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] C translation question

2016-10-24 Thread Lars
On Mon, October 24, 2016 5:20 am, José Mejuto wrote:
> El 24/10/2016 a las 1:40, Lars escribió:
>
>
>> Hi, what is the status of automated conversion tools? Last I remember
>> reading about them was when I read a delphi page on how to convert
>> header files. Are you saying that nowadways you can actually convert
>> plain C code to fpc, not just header files but all C code? Just certain
>> types of C code?  Are there any competing tools or everyone uses just
>> one main tool?
>
> Hello,
>
>
> I don't know, wrote this tool to help me in the past to translate Zint
> barcode source

...

> It is far away from a real code translator,

...

> It uses GoldParser so maybe it only works in Windows :-?, only very
> basic "C" is handled and is mostly function by function oriented.
>
> If you want to test it I can provide .exe or source code, but do not
> expect it to translate anything far than some trivial functions.
>

Do you have github account... or sourceforge, I think a few other people
may find it useful...

My dream is some day to convert this:
http://duro.sourceforge.net/

to freepascal or GoLang, however I don't really feel like doing it all
manually, would rather automate a lot of it.

AFAIK it's plain C, been a while since I looked at it.

There is more C code I'd like to convert too, and I'm sure others would be
interested in your source... But it is up to you, I don't know if you just
don't feel like making it public on github or sourceforge
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] C translation question

2016-10-30 Thread Lars
On Tue, October 25, 2016 3:31 pm, José Mejuto wrote:
> El 25/10/2016 a las 3:56, Lars escribió:
>
>
>>> If you want to test it I can provide .exe or source code, but do not
>>> expect it to translate anything far than some trivial functions.
>> Do you have github account... or sourceforge, I think a few other
>> people may find it useful...
>
> Hello,
>
>
> No sorry, no github, sourceforge (maybe yes, I can not recall).
>
...
>  maybe I should open a github account :-)

Code that is locked away on someone's hard drive is much less useful than
if publicly published :-)
In fact I have a lot of code on my drive that should be uploaded. Just
that I'm tired of learning new revision control systems, I was already
getting used to SVN when they pulled the plug on that and no one uses it
much any more as github is hot with the new kids on the block these days.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] C translation question

2016-10-30 Thread Lars
On Sun, October 30, 2016 4:40 pm, Graeme Geldenhuys wrote:
> On 2016-10-30 21:12, Lars wrote:
>
>> as github is hot with the new kids on the block these days.
>
> Yes, for good reason! Though I would correct your statement as "Git is
> hot...".  You don't have to use GitHub or any other public Git repository
> hosting environment.
>

I considered just using an SVN account elsewhere since I know SVN
already.. however the issue is, no one uses svn any more (I know people
use it) so for sharing code you pretty much have to use github and follow
the other sheep.  I don't mind the github GUI, in fact it's web based
portal is extremely good. I'm just skeptical of github being replaced by
yet another tool in 3 years just as CVS was replaced by SVN, and SVN
replaced by CVS.

I think the reason github is successful is because it has a wicked GUI
interface... github.com. Compared to the crap you see on source forge with
their broken ugly CVS viewers in html, or svn viewers.

The issue with github is that it encourages a lot of forking rather than
working together as CVS did.

Actually that begs the question, does freepascal still use SVN as their
development revision system? I'm completely out of touch with what's
happening with fpc dev
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FreeBSD distro with fpc as star.

2016-11-04 Thread Lars
On Thu, November 3, 2016 4:33 pm, Graeme Geldenhuys wrote:
> On 2016-11-03 20:57, Paul Breneman wrote:
>
>> The short/small video showing the same program being compiled and run
>> for 5 systems (FreeBSD 64/32, Linux 64/32 and Windows 32 bit) is *very*
>> nice!
>
> Yes, its even simpler to do cross-compiling with polYdev that it is with
> Code Typhon. Fred did a fantastic job.
>


Interesting! I've always been interested in a painless headache free way
to cross compile; so does polYdev not include lazarus and only focuses on
fpc/mse/fpgui?  If you wanted to cross compile a lazarus app... no go?
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FreeBSD distro with fpc as star.

2016-11-07 Thread Lars
On Mon, November 7, 2016 2:48 am, Michael Schnell wrote:
> I understand that you suggest you can't build the Lazarus IDE with
> defining  fpGUI or CustomDrwan  instead of Qt or Gnome (or Windows or
> Cocos).
>
>

Does lazarus even know about fpGUI I thought fpgui was never a part of
lazarus.. did someone use fpgui with lazarus?

Or you were mistaken to think fpGUI was an option in lazarus?

Sorry I don't know myself, I'm not up to date on these things

I always remembered fpgui as a non visual development that was separate
and never integrated in any way with lazarus widget set. Did this change?
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FreeBSD distro with fpc as star.

2016-11-08 Thread Lars
On Tue, November 8, 2016 2:56 am, Graeme Geldenhuys wrote:
> Yes, that changed about 9 years ago. :) And no, fpGUI is *not* a non
> visual development environment. fpGUI comes with its own Visual Forms
> Designer, Help Viewer, demo IDE and many more.

Thanks for clarifying.  I have always wanted to try fpGUI, but it's always
the same fear that stops me:  like msegui, the issue is there is no
torry.net for it with years and years of contributed components.  It seems
like a good tool to start a project in, if you don't require some special
component from torry.net or lazarus.  I always end up needing to pull in
some component from the internet at some point, I tend not to write a pure
GUI app that uses no one elses components.

I hate this fear that I have, because it causes me to stick to using
delphi since I know I have an insurance plan available (torry.net) if I
need a component that I don't feel like writing myself, that someone
already else has.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FreeBSD distro with fpc as star.

2016-11-08 Thread Lars
On Tue, November 8, 2016 2:45 am, Graeme Geldenhuys wrote:
> What Fred did with polYDev is create a minimal (read very small) fully
> functional FreeBSD install, that supports desktop development using FPC,
> includes a IDE (ideU a fork of MSEide with tons of custom modifications)

Does ideU support multiple programming languages as an editor? Without
trying it myself, for example, does it include multiple syntax
highlighters? can you write your own syntax highlighter?  Mseide seems
mostly based on fpc and not as many other languages, although I heard that
Martin sometimes does C development in mseide.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] New Feature: 'Management Operators'

2016-11-08 Thread Lars
On Tue, November 8, 2016 1:47 am, Maciej Izak wrote:
> 2016-11-07 22:24 GMT+01:00 African Wild Dog :
>
>
>>
>> I saw on the bug tracker a patch submission by Maciej Izak about the
>> feature "Management Operators".
>>
>> This feature is related to Automatic Reference Counting?
>>
>>
>
> Yes. We have a working ARC objects

Can someone briefly explain what this means for code?

Is this related to garbage collected heap allocated objects and similar,
without using a garbage collector but using reference counting?

Sorry if I am way off base, I just have no idea what it is...
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FreeBSD distro with fpc as star.

2016-11-08 Thread Lars
On Tue, November 8, 2016 4:04 am, Michael Schnell wrote:
> On 08.11.2016 03:12, Lars wrote:
>
>>
>> Does lazarus even know about fpGUI
>>
> Version 1.6 on Windows: even in the GUI:
> Project -> Project Options -> Additions and Overrides -> Set
> "LCLWidgetType" -> Drop Down selection Value "fpgui".
>

I see. Also Graeme's email explained it too. However, how compatible are
these widget sets with each other? Since they are coded with entirely
different styles, you can't just select fpgui and recompile the app,
right? You have to take an entirely different coding approach. So you
weren't trying to imply that lazarus, could be recompiled to use fpgui
based widgets inside the lazarus exe/elf itself? i.e. a lazarus ide, that
is based on fpgui widgets, so it could run on pure X and no gtk/kde
needed. To me that would seem like a huge leap. If possible, almost magic.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FreeBSD distro with fpc as star.

2016-11-08 Thread Lars
On Tue, November 8, 2016 3:24 am, Michael Schnell wrote:
> On 08.11.2016 03:12, Lars wrote:
> "FpGUI" used to be an option (one of a selection of Widget Types,
> together with e.g. "GTK2", "CustomDraw", ...). At some point in time the
> "WidgetType" menu in the project options had been replaced by a
> possibility to set the appropriate Macro Value in "additions and
> Overrides".

Doesn't fpgui take a different approach to programming, so if you start a
project in win32/gtk style, you can't easily port it to fpgui due to
enormous differences here and there in the way gui programming is done..

As I'm out of touch with fpGUI (really want to try it, just a matter of
making time), I'm ignorant on this. But it's not like you can just flip a
switch and recompile a existing lazarus app to use fpGUI that was
originally written for win32/gtk/kde style programming?
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] New Feature: 'Management Operators'

2016-11-10 Thread Lars
On Wed, November 9, 2016 7:11 am, leledumbo wrote:
>> anyway probably I have no motivation anymore to continuing my work.
>
> Too bad, if only at least the patch for this feature is integrated, I can
>  start arguing to my employer again that Pascal has simple, user
> selectable garbage collection mechanism. I really wanna know who's the
> person that you mention in your g+ post.
>
>

FPC will have the garbage collection, but the question remains what
happens in Delphi? Would delphi create a similar feature, but make it
incompatible with fpc? Once again we arrive at the issue of
standardization not being pascal's main advantage This will be an fpc
extension only?

Would be interesting to see if Embarcadero has even heard of such an idea
or plans to implement it (or already has something like it?). Would be
good to bring it up with them if not already, as many fpc users are also
delphi users. If a fpc user gets used to writing code a certain way in
fpc, it would be hard to port all that code to delphi.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] New Feature: 'Management Operators'

2016-11-10 Thread Lars
On Wed, November 9, 2016 2:40 am, denisgolovan wrote:
> Yes. Mostly.
>
>
> More general advantage is that this feature might finally bring
> FreePascal back into league of languages having nice support for value
> types (as opposed to OOP atrocities). To put it in other words, functional
> style might become both feasible and sufficiently fast in FreePascal.
>
> IMHO, that is one of the most valuable additions to the language in
> years.
>
> BR,
> Denis
>
>
>

Does this remove the amount of "object.free" code seen all over the place?

I.e. is the intent to have something like an "auto" freed object,
discussed long ago on the fpc list, literally many years ago... but I
remember Michael V. C. saying something about it having some difficulties
and road blocks for being implemented for reasons I cannot remember.

I do find the biggest disadvantage of delphi/fpc code, to be all the
"Free" and creates scattered throughout code, which has nothing or little
to do with the logic of the application and is just code bloat (takes up
editor space, adds not much useful, similar to the allocations required in
C programs to work with strings instead of it being automatic).


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


Re: [fpc-pascal] A serious Memleak using delegates/implements (was: Delegate Interface class does not seem to be referenced counted)

2016-11-10 Thread Lars
On Wed, October 5, 2016 9:54 pm, Martin Schreiber wrote:
> On Thursday 06 October 2016 00:16:22 Tony Whyman wrote:
>
>> On 05/10/16 23:03, Graeme Geldenhuys wrote:
>>
>>> Martin Schreiber recently mentioned in another Interface discussion
>>> that there is a very good reason he doesn’t use COM style
>>> interfaces… Reference Counting!
>>>
>>
>> Used properly reference counted interfaces are very powerful and allow
>> for some very elegant programming. Do you complain about AnsiStrings?
>> They are reference counted. Would you really want to have to free every
>>  string explicitly? Dynamic arrays are similarly reference counted.
>>
> Reference counting is great for simple types like strings and dynamic
> arrays but is a nightmare with the venturesome mixture of COM-interface
> and classes from Delphi. Even reference counting for complex classes is no
> good idea IMO, I fear the times when FPC will implement ARC.
> I don't think that a programming language should hide more and more of the
>  internal working of the code he writes from the programmer. Take a look
> at the modern C++ programs; the LLVM-compiler is a good example. It is
> horrific slow. Stepping through the code shows that there are complex
> multi-level dynamic type conversion and dataaccess routines at almost
> every statement. The typical C++ programmer does not need to care about
> because the programming language takes care for the boring tasks. The
> typical C++ programmer actually *does* not care about performance because
> competing programs are not faster; they are written in a modern
> programming language too... Recently I had to revive my stone old AMD-K6 PC
> with Windows 95. What marvel, that relict with its age-old applications
> provides a better user experience, is snappier, more convenient and more
> productive than my newest Linux machine with the modern desktops and
> applications.
>
> Martin

Replying to an old thread in my inbox. Apologies if it's obsolete as it is
a month old.

Martin, as you know, Windows 95 is mostly coded in plain C, so guess what
that meant: you had to reboot your pc every day to reset all the memory
leaks. So your idea that we should not be hiding code with more
abstraction layers is a double edged sword. Windows 95 is a very zippy,
fast, snappy operating system. But it also was not garbage collected so
had memory leaks due to poor programming in plain C.  Remember when people
migrated over to Windows 2000 and Windows XP and found that they no longer
needed to restart their PC daily to reset the memory leaks?

 Sometimes my windows 98 computer would last for a week, and that was
about it before I had to restart. Usually I had to restart every 1-3
days. And why is that? Because windows 95/98 did not have an abstract
programming language in place which hid details. It's all manual memory
management which causes tons of bugs. And these bugs are the same issue
seen in all kinds of delphi/lazarus apps

Admitting, however, that Windows 2000 and XP did not migrate to any
garbage collected language, they just improved the old buggy code so that
there were less memory leaks and now instead of rebooting your PC every
day or 3 days, you can wait a month before rebooting, or sometimes a
couple weeks, or sometimes a week. But there are still bugs in
win2000/windows10/windows7 which cause me having to reboot my PC.  And
wow, Firefox needs to be constantly restarted, as the memory leaks grow
out of control. But that's not a plain C app.

At the same time, I'm also scared of reference counting as you are, for
classes, as garbage collection mechanism. But since you are against hiding
details from the programmer, what's your opinion of Oberon garbage
collection that Wirth designed, if it was somehow implemented in FPC?
Likely that won't happen. However you say you are against hiding too many
details from the programmer (abstraction) so you think Oberon's garbage
collection system is too high level and would prefer to free and create?

To keep it on topic, related to fpc, and to not divert to oberon
discussion only: are you saying that if somehow and oberon like garbage
collection was implmented in fpc you'd be against that as it is too
abstract, or are you saying you are just against reference counting, but
would accept an Oberon like garbage collection? Unfortunately, that means
more like a new programming language rather that continuing fpc as it is,
likely. As oberon is designed to be that way, to handle garbage collection
and even module unloading/loading at run time, whereas fpc not so much.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] A serious Memleak using delegates/implements (was: Delegate Interface class does not seem to be referenced counted)

2016-11-10 Thread Lars
On Thu, November 10, 2016 11:04 pm, Martin Schreiber wrote:
> On Friday 11 November 2016 04:21:31 Lars wrote:
>
>>
>> Replying to an old thread in my inbox. Apologies if it's obsolete as it
>> is a month old.
>>
> I don't think such themes are allowed in fpc-pascal.

If an oberon like garbage collector, instead of reference counting, could
be somehow implemented into fpc, then it's still on topic.

However, oberon garbage collector is likely to alien to apply to fpc.
I just wonder, since fpc is based on Wirth's work, if any fpc developers
have looked into how oberon does garbage collection, and applied this
knowledge to fpc. I tried to keep it as much on topic, in that sense - but
I understand it's not 100 percent fpc (as it currently stands) related.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] C translation question

2016-11-15 Thread Lars
On Sun, November 13, 2016 2:50 am, Bo Berglund wrote:
> On Sun, 30 Oct 2016 21:15:03 -0600, "Lars"
>  wrote:
>
>
>> The issue with github is that it encourages a lot of forking rather
>> than working together as CVS did.
>
> We still use CVS

I just wish CVS and SVN had as nice of a GUI front end (like github).
That's the one thing I really like about git is the nice GUI access,
simple readme system for projects etc. With CVS and SVN gui's and website
front ends I never found anything that pleasing, although I haven't looked
at third party front ends.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] MySQL 5.7 and FreePascal

2016-11-19 Thread Lars
On Sat, November 19, 2016 12:05 pm, Terry A. Haimann wrote:
> Is it possible to connect to MySQL 5.7 using TSQLConnection or will  I
> have to downgrade my MySQL Version?  I have FreePascal 3.0.0 which appears
> to be the most current version.  I have it on a Ubuntu  Linux 16.10 X86-64
> system.


You probably have to go into the fpc unit source code and see which
version of mysql it links against, if any comments in the file. Or someone
may know which mysql it is linked against off the top of their head
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Underscores in numerical literals - grouping

2016-11-22 Thread Lars
On Tue, November 22, 2016 6:12 am, Martin Schreiber wrote:
> On 11/21/2016 03:46 PM, Graeme Geldenhuys wrote:
>
>> The age old rule
>> of programmer source code always being in a mono-spaced font is
>> ridiculous for this day and age.
>>
...
> A programmer scans code most the time vertically
> or block by block and not horizontally and word by word as normal text. And
> for that a monospace font is much better suited because of the straight
> vertical character columns.

Agree. The idea that reading code is like reading a novel, was put forth
by IMO a somewhat idiot, Rob Pike in this particular case, as far as I
remember. His argument was that C code was easier to
read_with_lots_of_underscores.

My counter argument was that underscores jump out like a symbol, like a
minus sign, so you pollute the code with symbols, and there is enough
space and symbols already littered throughout the code.

As for underscores in numbers, it is an interesting idea but I see delphi
compatibility issues coming up any code you want to port has to be
converted to non underscores, or delphi would have to implement the
feature at some point. Another mode switch if check in the compiler, in
possibly more than one place.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] how to use Default to replace this ' FillChar(aRecord, sizeof(aRecord), 0);

2016-12-05 Thread Lars
Do you know about this feature:

var
  SomeRec: TSomeRecord = ();

This initializes the record without needing fillchar.
I assume your "Default()" call initializes the record initially. You can
eliminate the default() call by initializing the record as part of your
declaration.

Some criticize this as being C++ like and not pascalish. I find it to be a
contract set up at the declaration stage without needing for ugly fillchar
hacks which seem like a mess... But old pascal programmers are used to and
like fillchar.

However, my email here may have nothing to do with what you are trying to
accomplish...  As you want a some kind of generic function to fillchar any
record, I guess... My solution above, is to use () to fillchar it to 0
without requiring any call to fillchar. If you want to add values other
than zero then you can set them up inside the initialization instead of a
blank ()

An interesting trivia note: delphi 5 doesn't seem to allow initialized
record declarations in local variables inside a procedure but allows it
for globals or unit variables...

Also the fpc compiler gives a warning:
Warning: Some fields coming after "" were not initialized

When using () to initialize a record... I'm not sure if this warning is
correct, as theoretically the compiler should in fact set all record
values to zero in the case of ()

Should this warning be looked at as a possible erroneous warning?

Again, sorry if my answer to your email has nothing at all to do with what
you are trying to accomplish!



On Mon, December 5, 2016 12:23 am, Dennis wrote:
> In this old statement, I don't need to know the type of aRecord
> but if I want to use Default, I have to know the exact type of the varaible
> aRecord and pass it to Default(aRecordType) e.g. aRecord :=
> Default(aRecordType)  //where var  aRecord : aRecordType
>
>
> Is it possible to use default without knowing the variable type? (it is
> because sometimes the type get renamed)
>
> Dennis
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
>

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


Re: [fpc-pascal] List of integers? Any class available in RTL or FCL to help?

2016-12-05 Thread Lars
This topic title brings back nostalgia as I needed an integer list before,
and found some, either in the contributed units section of fpc, or in some
old turbopascal units by a company.. TurboPower with Julian Bucknall, or
something similar.  As I looked through the code, I wondered if fpc and
delphi really needed something more like a general purpose associative
array or similar.. as it seemed people were reinventing it all the time
over and over.

I believe I found some code on sourceforge, maybe it was that company that
used to sell code for turbopascal called TurboPower, which I think Julian
Bucknall worked for and they made casino software that ran on dos and
powered casino machines.. But I could be recalling incorrect.

There is even old classic 1980's stuff like this:
http://www.drdobbs.com/cpp/container-object-types-in-turbo-pascal/184408235
An article in 1989 by Anders himself But that may be unrelated.

With data structures like this it does seem people are reinventing it,
especially when people use a TStringList to store integers (I have done
this before, a shame indeed, bad programming practice)... Or complex
generics which just seems like over engineering, but at least it works.
Using plain old arrays, requires reinventing the wheel because you end up
writing duplicate functions for each array type (array of string) instead
of a general purpose algorithm for many types..

I guess that is why some people prefer dynamic typed languages because you
can write general algorithms for many types without reinventing the wheel.
But with static languages it is still possible, as GoLang has a
associative array, maps, etc without resorting to complex generics.

Sometimes I got so tired of inventing a intlist that I just ended up using
a TStringList to store integers, which... was bad. but worked.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] how to use Default to replace this ' FillChar(aRecord, sizeof(aRecord), 0);

2016-12-07 Thread Lars
On Mon, December 5, 2016 4:46 am, Dennis Poon wrote:
>

>
> Lars wrote:
>
>> Do you know about this feature:
>>
>>
>> var SomeRec: TSomeRecord = ();
>>
> This is good for global variable.
> But I wonder whether it has effect in procedure's local variable since
> it requires the compiler to clear the record on the stack (which is at
> different location every time).

I tested it and it seems to compile, and then the value is in fact 0 when
I try to access it and do a showmessage(inttostr(rec.i))... where rec.i is
an integer...

But just because it compiles and just because it is zero this time, does
not mean.. it is consistent. So this needs to be confirmed.

It is weird that fpc allows a local initialized var to compile, but delphi
5 rejects it...  Delphi 5 is older and may have not had as advanced stack
technology as fpc ;-)

Another trick is to setup a default global, and then just assign the local
var to the global (copying the contents) which resets the local to the
global.. i.e. if you assign one global record () default 0 contents, to a
local... using:

var
  GlobalDefault := TSomeRec = ();

procedure ...
var
  local: TSomeRec = ();
begin
  localrec := GlobalDefault



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


Re: [fpc-pascal] List of integers? Any class available in RTL or FCL to help?

2016-12-13 Thread Lars
On Mon, December 5, 2016 7:05 am, denisgolovan wrote:
>
> And generics are complex because they lead to more accidental complexity
> for reasons given earlier.
>
>

The Golang approach is to use interfaces, similar to freepascal's VARARGS
but a bit different.. and more powerful. Interfaces, an overloaded term,
not to be confused with COM/Corba interfaces...

i.e. a function that can take multiple types of "stuff".. without ever
using generics or templates.

Someone on this list (maybe even me) mentioned that writing functions for
arrays requires writing code multiple times that does basically the same
thing but for different types...

You might be interested in this article:
http://wiki.c2.com/?IncludeFileParametricPolymorphism

I was able to make FPC compile code that took in multiple types to a
function, without using generics, but just using fps's include file
system. I believe golang's interfaces solve the issue more elegantly than
using include file tricks, as the include file trick was just a prototype
to prove it was possible..

A general purpose function that handles multiple types of arrays without
rewriting the code for each array type looks like this:

procedure AddItemToArray(
  const item: {$I T.inc}; var arr: {$I TArr.inc}); overload;
var len: integer;
begin
  // below is the same for EVERY type! Reuse, Reuse!
  len:= length(arr);
  setlength(arr, len+1);
  arr[len]:= item;
end;

Where $I T.inc defines the type being used.

Maybe I reinvented generics. Advantage of this, is no OOP (object
orientation) required and it therefore works on any procedural code or OOP
code, not just OOP code alone.  One reason I dislike generics in modern
languages is that it almost always requires object orientation to be used
and you cannot program "generally" using procedural style coding. My
include file parametric polymorphism allows procedural code to be written
(such as dealing with simple arrays) generally.

Golang does it via interfaces..

Dynamic typed languages like php and python can do it because of dynamic
typing allowing any type to be passed in "generally" without the compiler
checking.. which IMO is a bug, not a feature.

VARARGS sort of allow one to program generally, by allowing a multi type
to be passed in, then you check it at run time... That's similar to
golang's interfaces but golang interface more powerful than a vararg.

By vararg I mean:
  CallSomeCode([arbitrary, amount, of, parameters, of, any, type]);

Where the square brackets allow you to pass in sort of an "array of any type"

It is interesting that golang has been able to create an interface that
can be sent in to a function/procedure, "generally", without resorting to
any generics or c++ tempting tricks.. But the disadvantage is you have to
check some things at run time, similar to RTTI or vararg checks...

if vararg.type = integer then..

if vararg.type = string then..

Whereas template systems tend to do these checks at compile time to save
the run time checks...

My include file parametric polymorphism trick, does all the checks at
compile time with no run time overhead.  But it's an include file trick,
not a language feature built in.  I may have invented a general purpose
generic way of writing code procedurally, which I find fascinating.. but
I'm tooting my own horn.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] List of integers? Any class available in RTL or FCL to help?

2016-12-13 Thread Lars
On Mon, December 5, 2016 6:37 am, Sven Barth wrote:
>
> Again: I don't see why anyone thinks of generics as complex. Your mail
> did not answer that in any way.
>

Well for one, at least in Delphi, it forces you to throw stuff into a
class that have no need. Like a simple array...

This:

http://stackoverflow.com/questions/23447612/how-to-handle-a-plain-dynamic-array-using-generics

Is much more complex than my IncludeFileParametricPolymorphism invention
that allows you to program arrays generally, without throwing stuff into a
class just because classes are the only thing the compiler knows about
generically. Why? Why should everything be forced into a class when it
need not be.  Even PHP, as much as I hate it, allows you to program
generally, on simple functions/procedures without forcing something into a
class.

But I don't know enough about fps generics to know if stuff needs to be
forced into a class, as I have to start using generics and testing it out
to really know. From what I've seen though, I'm certainly not and have
never been a fan of less than and greater than signs  They tick me off
enough in HTML enough. But that's not really a real point, that's just a
pet peeve to deal with...
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] List of integers? Any class available in RTL or FCL to help?

2016-12-14 Thread Lars
On Wed, December 14, 2016 12:09 am, I previously wrote:
> similar to freepascal's VARARGS
>

Correction: I really meant ARRAY of CONST, but varargs is kind of related.

i.e.:
http://www.freepascal.org/docs-html/3.0.0/ref/refsu70.html#x181-20300014.4.6

is a simple way of generically programming, where you check what is being
passed in at run time instead of at compile time..

but you can't do things more powerful like send structures (records) or
more complex things like arrays, generically, whereas golang interfaces
allow such.

Apologies for "varargs", that's just what came to mind.. I really meant
"array of const". Even "array of const" is a strange name for this tool.

I think I once thought, can I make an "array of array of const" to try to
expand on the power of array of const. Which seems like a silly idea, but
academically interesting. Also, Varients are related to general
programming (generic). But no one likes variants, as it is like dynamic
typing.. Not sure if you can create an array of variant and program
generally that way. Doesn't really matter as people hate variants and tend
to avoid them.


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


Re: [fpc-pascal] List of integers? Any class available in RTL or FCL to help?

2016-12-14 Thread Lars
On Wed, December 14, 2016 12:35 am, I previously wrote:
> But I don't know enough about fps generics to know if stuff needs to be
> forced into a class, as I have to start using generics and testing it out
> to really know.

Sorry, FPS --> FPC. My MacOs laptop that I'm on, testing it out, keeps
automatically spell checking stuff... and made fps become fps

So if in my last emails you wondered what I mean by "fps generics" or
"fps" which unfortunately came up several times... It's "FPC" that I
meant..

Have to figure out how to turn off macOS spell check...

Me a Mac newbie, and, you can tell that.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] meta data of files

2016-12-14 Thread Lars
On Wed, December 14, 2016 11:57 am, Marc Santhoff wrote:
> Hi,
>
>
> I'd like to read out meta data from files. is there any pascal code
> supporting this task?
>
> This is about reading the comment of zip files, the author and
> description of word processor files (open document format) and so on.
>
> TIA,
> Marc
>
>
>

You may check out total commander plugin source code..

Although it may be in Delphi, you could convert to Laz/fpc

There are a lot of total commander plugins that deal with MP3 meta data
and such... not sure about Open Document though..

Is meta data in files some standard, so that the meta data in an mp3 file
is similar to a word process file? I have a hunch this is not going to
help you.. as it's completely different
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to split file of whitespace separated numbers?

2016-12-24 Thread Lars
On Fri, December 23, 2016 4:49 am, Howard Page-Clark wrote:
> On 23/12/16 08:14, Bo Berglund wrote:
>
>> Is there a quick way to split a string of whitespace separated values
>> into the separate members?
> It is possible that a custom string parser (something along these lines)
> might improve your processing speed:
>
> type TDoubleArray = array of Double;
>
>
> function StrToDblArray(const aString: string): TDoubleArray;
> var c: Char;

And as soon as char is involved, unicode gets screwed up

Am I right, am I right...

But if he is not dealing with any unicode data and it is all simple chars,
should be okay.

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


Re: [fpc-pascal] How to split file of whitespace separated numbers?

2016-12-24 Thread Lars
On Fri, December 23, 2016 12:54 pm, Graeme Geldenhuys wrote:
> On 2016-12-23 18:27, Marco van de Voort wrote:
>
>> Writing or even worse, reading/debugging regex is about the most
>> intensive effort there is IMHO.
>
> So is standard programming code - if you don't know the syntax or how it
> works. ;-)  Also the reason why I posted a couple of links to regex sites
> to get the original poster started (in case he doesn't know regex). Here
> is another link (by the author of EditPad Pro), who really knows his
> regex!
>
> http://www.regular-expressions.info/tutorial.html
>

Next thing todo: implement PERL inside pascal programs, compiled in perl.
Then, realize, why you didn't originally want to go there ;-)
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FastHtmlParser does not fire OnFoundText on e.g. empty table cell

2016-12-31 Thread Lars
On Fri, December 30, 2016 1:22 pm, Graeme Geldenhuys wrote:
> On 2016-12-29 18:43, Bart wrote:
>
>> Is this intended behaviour?
>>
>
> I'm not sure. I used FastHTMLParser 2+ months ago and discovered a
> couple of bugs in it, and similar behaviour to what you mentioned. I wrote
> some unit tests for it and fixed the bugs I found. I'll make a not to
> publish my changes and test suite.
>

I have plans to put fast html parser on an official git hub so that any
issues can be reported centrally

Thanks for finding bugs (assuming they are not just technicalities as Bart
was saying)
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FastHtmlParser does not fire OnFoundText on e.g. empty table cell

2016-12-31 Thread Lars
On Thu, December 29, 2016 12:09 pm, Bart wrote:
> On 12/29/16, Bart  wrote:
>
>
>> Is this intended behaviour?
>> If so, could it be made configurable to do fire the OnFoundText event
>> in such cases?
>
> Never mind, I did not think this through.
> I solved my problem in a better way (it should never have depended on
> the OnFoundText event in the first place).
>
> Sorry for wasting your time.
>
>

This brings some kind of Deja Vu as I may have had a similar issue once
upon a time... but cannot remember ;-)
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FPC clean room project

2017-01-06 Thread Lars
On Sun, January 1, 2017 10:23 pm, Mr Bee wrote:
> Hi all,
> There's someone accusing that Free Pascal (and some parts of Lazarus) is
> just a reverse engineering of Delphi. Even he said some codes of FPC/Laz
> are taken from Delphi (and Kylix). This is a serious allegation. I know
> that isn't true. Or is it? ;) Can anybody elaborate on this? I'd like to
> debunk the allegation but I don't know where to start and the evidence
> for it. Thank you.

Well considering the Borland/Codegear/Embarcadero has actually used FPC in
one of their products they likely have the same allegations, just no one
makes a fuss about it the other way around...
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FPC clean room project

2017-01-06 Thread Lars
On Tue, January 3, 2017 5:47 am, Dmitriy Pomerantsev wrote:
> Doesn't matter since FPC license allowing that.
>
>
> Dmitriy Pomerantsev.


Well, Kylix, AFAIR was actually released under GPL at one time too, so in
a way delphi already allowed it too (although, more a LGPL would have
really helped)...

I think it was brought up in the Steve Trefethen fiasco years ago
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FPC clean room project

2017-01-06 Thread Lars
On Thu, January 5, 2017 2:46 am, Graeme Geldenhuys wrote:
> I also know from first hand experience that Embarcadero has been made
> aware of CodeTyphon's copying and distribution of FireMonkey (called Orca
> or something in CodeTyphon).


What does this product allow? Compilation of firemonkey apps using fpc
compiler instead of delphi?
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FPC clean room project

2017-01-06 Thread Lars
On Tue, January 3, 2017 6:10 pm, Snorkl e wrote:
> They might with a change of ownership, who knows these days,  but the
> fact they did use it in the past would not look good for any litigation
> from some bottom feeder.

The fact that they use FPC, means they likely reverse engineer FPC and
apply their own hacks to their own compiler for multiple targets based on
FPC engineering..

i.e. they don't even need to reverse engineer FPC, they just have to dip
their eyes into the source code... And woops, there comes the problem:
Delphi is likely stealing from FPC too as their eyes have seen what cannot
be undone... they've peered into the FPC source code guaranteed.. I bet.

i.e. when they decide to target multiple platforms they have a nice demo
to look into which already does it: fpc.

Now I am not trying to insinuate anything here, but "it goes both ways"

As Michael Van C. once said, why isn't Borland also practicing clean room?
who is to say, since their development model is closed source, that their
compiler has no violations in it, that rip from FPC?  With FPC the code is
open so you can tell. With delphi, it's closed development, so you cannot
peer into their compiler sources and check to see if there are violations.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FPC clean room project

2017-01-06 Thread Lars
On Fri, January 6, 2017 8:59 am, Graeme Geldenhuys wrote:
> On 2017-01-06 15:49, Lars wrote:
>
>> What does this product allow?
>>
>
> CodeTyphon distributes the source code of Embarcadero's FireMonkey
> predecessor (previously known as VG-Scene or something), but rebranded as
> "Orca". Neither FireMonkey or its predecessor is/was open source.
>

LOL..

Okay but what's the point of it? to be able to compile firemonkey like
applications without buying delphi?
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FPC clean room project

2017-01-06 Thread Lars
On Fri, January 6, 2017 9:21 am, Graeme Geldenhuys wrote:
> On 2017-01-06 16:14, Lars wrote:
>
>> Okay but what's the point of it? to be able to compile firemonkey like
>> applications without buying delphi?
>
> Yes, you can build hardware accelerated GUI applications using that
> toolkit.
>

Okay. hold on a second.  GUI applications, need hardware acceleration...
since when?  I guess this could be useful for animation based apps that
need to be zippy fast...?

AFAICT, gui applications, ever since windows 3.1 days on 33mhz computers,
were fast enough and needed no acceleration for basic things like buttons,
text, etc.

So does the hardware acceleration come in handy when you need to animate
something and make the gui app almost like a video? Scientific demos of
particles bouncing around?

What are the use cases for this?
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FPC clean room project

2017-01-07 Thread Lars
On Fri, January 6, 2017 12:51 pm, Sven Barth wrote:

> Ehm... Delphi's compiler is written in C++, not Delphi as far as we
> know. Also their NEXTGEN compiler is utilizing LLVM, something we won't
> purely do.


Yes the exe signature was c/c++

That does not forgive copyright just because different language is used..

Any fpc code can be easily converted to C code

In fact that hides copyright violations a bit as it masks them by
converting to a new language.

But this is just insinuating..
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Untyped var params

2017-01-07 Thread Lars
On Sat, January 7, 2017 4:29 am, Ryan Joseph wrote:
>

>> On Jan 4, 2017, at 11:07 PM, Dmitry Boyarintsev
>>  wrote:
>>
>>
>> Treat is as a pointer (it's an implicit pointer anyway)
>>
>>
>
> So I need to need to use Move to write memory directly to “var
> something”? That makes sense I guess and could be useful is some cases
> but not like I was planning. Thanks for helping.
>

Why do you need to deal with it directly rather than indirectly setting up
something to access it...

What is the advantage of writing directly in your case..
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FPC hardware accelerated GUI apps. Why?

2017-01-07 Thread Lars
On Fri, January 6, 2017 10:06 am, Tomas Hajny wrote:
> Hello,
>
>
> Could be potential further discussion about FireMonkey moved to
> fpc-other, please? I don't think that it's still related to FPC...
>
> Thank you
>
>
> Tomas
> (one of FPC mailing list moderators)
>

Fine, let me put it this way to keep it 100 percent on topic.

If FPC was able to create hardware accelerated GUI apps (nothing to do
with firemonkey... just in general if it was able to), is this useful?

How so?

What advantages do hardware accelerated GUI apps offer?

The way I see it is 99 percent of all GUI apps are fast enough back in
windows 3.1 days or the early days of X11 on bsd/linux.  There needs no
"acceleration".

However, on the other hand: animations, videos, scientific... maybe?

If FPC was able to target hardware accelerated GUI (or if it already does)
then what advantages would this offer people?  There must be some reason
for hardware accelerated GUI apps.

My buttons click fast enough without any accelerations on Windows 3.1...
on a 33mhz computer...

But maybe it's to do with flash style animations, video game like
interfaces for apps... 3D apps?
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Untyped var params

2017-01-07 Thread Lars
On Sat, January 7, 2017 2:52 pm, Bart wrote:
> On 1/7/17, Andrew Hall  wrote:
>
>
>> If you cast your “something” to a typed pointer, the compiler will
>> do the work for you in the usual way:
>>
>
> But if you know that at forehand (and you know, since you cast it),
> why then use an untyped var parameter at all?
>

Some brave soldiers once tried to reinvent generics using these tricks..


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


Re: [fpc-pascal] ppcjvm issues

2017-01-07 Thread Lars
On Sat, January 7, 2017 10:09 am, Jon Foster wrote:
> On 01/07/2017 03:06 AM, Tomas Hajny wrote:
>
>> On Sat, January 7, 2017 03:12, Jon Foster wrote:
>>
>>
>>
>> Hello,
>>
>>
>> You didn't mention that you weren't subscribed to the list, but since
>> this seemed to be the case, I included your address in Cc:.
> Thanks for this. I get a lot of mail from the FPC lists ... but it looks
> like its from the devel list. I originally subscribed to this list in Feb.
>  2015. I must have been evicted. Not sure why. I've re-subscribed. I'll
> try not to get booted again.
>>> The second issue I ran into:
>>>
>>>
>>> function f(x, y: integer): float; begin result:=float(dy)/float(dx)
>>> end;
>>>
>>> When attempting to compile this it tells me that "float" is
>>> undefined. I think I'm missing something here. "float" is the native
>>> Java name for
>>> their base floating point type and its a valid type for FPC. If I use
>>> "single"
>>> instead it will compile. Seems odd.
>> I can't comment the first part, but where exactly is a type named
>> "float"
>> defined in FPC (which unit)? E.g. single is defined in unit System and
>> thus available for all FPC programs automatically. If some unit defines
>>  "float" (not sure about that, but it might be the case). I can see the
>>  System unit for Java defining "jfloat" as an alias to single - maybe
>> you meant that one?
>>
>> Hope this helps
>>
> Yes, you're right. Sorry too many languages to deal with. And working in
> this quasi-java-fpc world is bending my brain.

This is one of the main reasons, I'm afraid of things like jvm/llvm and
even objectivefpc macOS mode because your brain starts juggling multiple
ideologies.. and your brain must have a modeswitch that is fuzzy (not
always switched in one mode, sometimes several) ;-)

> So to sum up:
>
> fpc doesn't have a float type. Java does. Since its in the "java"
> namespace its named "Jfloat" in FPC. The native FPC equivalent is single.
>

Well, fpc has Math unit which has float related tools and type that is not
quite the same. But as another poster said, that float in math unit
doesn't match up  to Java's
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Size of program vs library ?

2017-01-14 Thread Lars

>>> Sorry to insist on that, but the size of fp library is very too big
>>> vs
> other libraries (C for example).


Except in the case of KOL applications where many of my KOL Dll's/Exe's
were smaller than any C/C++ tool could ever create... But KOL is window's
specific mostly. Someone ported it, AFAIR, to linux using some gui
widget set, but I don't remember how far that got
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Free Vision etc. form editor

2017-01-14 Thread Lars
On Fri, January 13, 2017 5:35 am, Mark Morgan Lloyd wrote:
> I've just come across
> http://forum.lazarus.freepascal.org/index.php?topic=18998.0 which was
> asking about a dialog(ue) editor for Turbo/Free Vision. The links it cites
> are dead, but the author's page is still available at
> http://web.archive.org/web/20151002202724/http://home.comcast.net/%7EJame
> sMClark5/Pascal/index.htm and the content of DIALEDIT3b.zip appears to be
> intact.
>
> The author's page says that it's now GPL3. Does anybody know whether
> there's a permanent repository for this anywhere, since we probably don't
> want it to vanish utterly?
>

Interesting - the FPide does not use visual editor or make use of this for
its dialogs?

> I'm not volunteering to do anything with this myself since I have rather
> a lot of problems right now. I only investigated because I was trying to
> salvage an antique Visual Basic for DOS manual which had been
> water-damaged.

Shouldn't take too long to just upload one zip file to a github account
somewhere... if you have, or someone has
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] ppcjvm issues

2017-01-14 Thread Lars
On Thu, January 12, 2017 2:08 am, Michael Schnell wrote:
> On 11.01.2017 11:25, Sven Barth wrote:
>
>>
>> We're talking about JVM here where garbage collections *must* be used.
>> So FPC does as well for that target.
>>
>>
> This of course is true. But if the class code is in fpc, fpc paradigms
> should be adhered, as well. and here the fpc code *can* e.g. explicitly
> allocate stuff that needs to be freed later, or e.g. can open a connection
> to whatever that needs to be closed later, and so (if not using ref
> counted objects) with such classes destroy() needs to be called (via the
> free()  chain).
>
> Regarding this, IMHO it would be good practice to always provide destroy
> and free, and if it's empty it does not harm to call it.
>

What if you are porting code to a non jvm... if you copy and paste
something and it has no free, you're screwed.

i.e. say you have some JVM algorithms that now need to be used in win32 or
bsd using the regular fpc compilation can't port them without
inspecting the code carefully for missing free's


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


[fpc-pascal] How to tell if file is locked, i.e. FileOpen in sysutils

2017-01-15 Thread Lars
The fileopen function returns -1 on error, but there is no way to tell if
the error is because of a lock, or another issue opening the file?

I'm interested in finding out specifically if a file is locked, as it
would be useful for example in a wiki to say to the user "File is locked
by another person contributing, please go back and refresh the page to see
updates and resolve conflicts"

If the fileopen function just returns -1 there is no way to tell if it is
a lock issue, or another file issue unrelated to locks?

http://www.freepascal.org/docs-html/rtl/sysutils/fileopen.html

Thanks!

Also, really appreciate whoever implemented file locking mechanism cross
platform as it was something I needed (would have even set up a bounty for
such).
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] FPC run (run program after compile)

2017-01-15 Thread Lars
Is there a way to compile a program with fpc at the command line and run
it right after?

Something like
  fpc run project1.pas -Fu../

The only thing I could find was InstantFpc, which may serve similar
purpose but not really the same as what I was thinking...

For some reason (I may remember incorrectly) I thought there was some work
being done to compile a program and then run it afterward a while back...
but maybe I'm confusing this idea with the InstantFPC idea.


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


Re: [fpc-pascal] PascalScript broken by FPC 3.0 ?

2017-01-15 Thread Lars
On Sun, January 15, 2017 7:04 am, Bart wrote:
> On 1/15/17, Mattias Gaertner  wrote:
>
>
>> Note:
>> You can use the Lazarus IDE macro $(FPCVer) in the "FPC source
>> directory". Then you only need to switch the compiler path.
>
> This requires the same directory layout for both compilers/sources.
> Typically the bindled compiler that comes with Lazarus is in
> $(Lazarus)/fpc/$(FPCVer)/
> and a stand alone installation of fpc will default to c:\pp (on Windows).
>
> I install fpc seperately and have all my fpc compilers and their
> sources  in c:\devel\fpc\$(FPCVer), which makes it easier in lazarus to
> switch.
>

Any idea how to manage multiple compilers at the command line...

rename fpc.exe to fpc224 and fpc300 or something?

Or just call the fpc using absolute path, but that may be annoying as it
clogs up the command line with verbose full path
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FPC run (run program after compile)

2017-01-16 Thread Lars
On Mon, January 16, 2017 2:55 am, Graeme Geldenhuys wrote:
> On 2017-01-16 07:06, Lars wrote:
>
>> The only thing I could find was InstantFpc, which may serve similar
>> purpose but not really the same as what I was thinking...
>
> If InstantFPC doesn't work for you, you could always compile the FPC
> Compiler into your "own" executable that does compilation and then
> running the resulting executable.

Indeed, would not be too hard... even a shell script like you say..

If anyone finds this idea useful of seeing your program run, right after a
compile, at the command line, it might be something to add to fpc. It is
similar to how when you press F9 in delphi or compile a program in
turbopascal/fpide it runs the program for you, without multiple
link/compile/run steps like GCC and old C compilers required.

As for instantFPC, that would maybe make pascal programs run on a
webserver just by uploading them.. which is very interesting more
research to be done there as to what has to be installed on the server for
that to work... some kind of fpc compiler will need to be on the server
and in what directories.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FPC run (run program after compile)

2017-01-16 Thread Lars
On Mon, January 16, 2017 3:08 am, Mattias Gaertner wrote:
> On Mon, 16 Jan 2017 00:06:59 -0700
> "Lars"  wrote:
>
>
>> Is there a way to compile a program with fpc at the command line and
>> run it right after?
>>
>> Something like
>> fpc run project1.pas -Fu../
>
> instantfpc -Fu../ project1.pas
>
>

Looks good...

>> The only thing I could find was InstantFpc, which may serve similar
>> purpose but not really the same as what I was thinking...
>
> And what are you thinking?
>
>

That instantfpc has catch22 like you cant compule multiple projects with
the same name, i.e. it caches file name only (caveat) whereas fpcrun would
compile it in current directory, as normal, no special cache dir needed

Also I am thinking about 3 million two thousand and eight other ideas at
the moment
Possibly a.d.h.d meds


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

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


Re: [fpc-pascal] FPC run (run program after compile)

2017-01-16 Thread Lars
On Mon, January 16, 2017 6:59 am, Mark Morgan Lloyd wrote:
> On 16/01/17 13:30, Mattias Gaertner wrote:
>
>> On Mon, 16 Jan 2017 05:22:14 -0700
>> "Lars"  wrote:
>>
>>
>>> [...]
>>> That instantfpc has catch22 like you cant compule multiple projects
>>> with the same name, i.e. it caches file name only (caveat) whereas
>>> fpcrun would compile it in current directory, as normal, no special
>>> cache dir needed
>>
>> Feel free to add an option like "--inplace" and send the patch.
>>
>
> This works
>
>
> #!/usr/local/bin/fpc.d/3.0.0/instantfpc --set-cache=./
>
>
> program Test; ..
>
>

Does instantfpc make it mandatory that you put this at the top of every
source file:
> #!/usr/local/bin/fpc.d/3.0.0/instantfpc --set-cache=./

fpcrun would not require this as it just compiles normally...

However making fpcrun.exe (trivial) would duplicate what instantfpc
already kind of sort of does, so I do not want fpc to ship two executables
that do the same thing (or similar)...

> except that the original file's getting modified to put // in front of the
> shebang which means that a second instantfpc run fails.
>

Interesting idea, to just cache it in the original project directory.

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


Re: [fpc-pascal] FPC run (run program after compile)

2017-01-16 Thread Lars
On Mon, January 16, 2017 3:59 am, Sven Barth wrote:
> Am 16.01.2017 08:07 schrieb "Lars" :
>
>>
>> Is there a way to compile a program with fpc at the command line and
>> run it right after?
>>
>> Something like
>> fpc run project1.pas -Fu../
>
> No, FPC is a compiler, not a "runner" or debugger. That would even be one
>  of the few points where patches would *not* be welcome.
>

fpcrun.exe is an alternative to "fpc run"

fpcrun.exe is trivial, and I can copy it into my fpc directory.. but
wondered if others needed it.  But I don't want to duplicate what
instantfpc does... so might be better to modify instantfpc.  Still,
fpcrun.exe would be trivial to make so that is still tempting...  as
instantfpc may require adding a parameter like Mattias was saying, whereas
fpcrun.exe would require no parameters.


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


[fpc-pascal] Does the system unit allow file locking/sharing?

2017-01-16 Thread Lars
The oldschool way of opening files using the system unit (no sysutils) has
the filemode variable..

system.FileMode := fmOpenRead;
...
Assign(...
Rewrite(...


Can this be used with file locking/sharing OR-ed options like:
  fmShareCompat
  fmShareDenyNone
  fmShareDenyRead
  fmShareDenyWrite
  fmShareExclusive

Or does file locking/sharing require using sysutils unit with fileopen:
http://www.freepascal.org/docs-html/rtl/sysutils/fileopen.html

Thanx!
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Does the system unit allow file locking/sharing?

2017-01-16 Thread Lars
On Mon, January 16, 2017 2:34 pm, I previously wrote:
> The oldschool way of opening files using the system unit (no sysutils)
> has the filemode variable..
>
> system.FileMode := fmOpenRead; ...
> Assign(...
> Rewrite(...
>
>
>
> Can this be used with file locking/sharing OR-ed options like:
> fmShareCompat fmShareDenyNone fmShareDenyRead fmShareDenyWrite
> fmShareExclusive
>
> Or does file locking/sharing require using sysutils unit with fileopen:
> http://www.freepascal.org/docs-html/rtl/sysutils/fileopen.html
>

To answer my own question... Looking into the fpc rtl sources I found that
DoFileLocking is inside sysutils, so likely system unit (old school
handling of files) cannot be used with locking at this stage.


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


Re: [fpc-pascal] ppcjvm issues

2017-01-17 Thread Lars
On Mon, January 16, 2017 2:40 am, Michael Schnell wrote:
> On 14.01.2017 20:36, Lars wrote:
>
>> What if you are porting code to a non jvm... if you copy and paste
>> something and it has no free, you're screwed.
> Sorry. I don't understand. AFAIK, in a non jvm project, free() always is
> provided (and used).

If you have a jvm project with lots of code and now want to start using
this code in another regular mode objfpc unix/win32 application...

Sorry I'm not familiar with the jvm fpc project (I have been meaning to
try it).

Delphi has some similar issues with garbage collected iOS development
where they have provided some fake release/free system to try solve the
issue, which, has the side effect of making garbage collected programming
much like non garbage collected programming which in a way defeats the
purpose..

i.e. if you have a fake free procedure that can be called, then why
program in garbage collection in the first place..
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Language constructs and types that dependent upon system unit

2017-01-19 Thread Lars
On Thu, January 19, 2017 1:28 pm, gabor wrote:
> I was hoping that maybe there is an easy answer. But I understand.
> Thanks.
>

The easy answer is just to use the system unit and have no fear...

The main issue with using fpc with C is when you try to use classes or try
to use C++ classes

As objects are not so portable across languages.. Every language has their
own object format.  Also strings, being reference counted, will cause some
issues unless you convert them to pchar when sending in as a read only to
C, or if C writes to the string buffer you have to send a buffer in that
is allocated by you (or a fixed buffer) rather than sending in an
Ansistring. Memory managers will conflict.  Or use shared memory manager.
But C knows nothing about what a modern pascal reference counted
ansistring is.. it has no information about it.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FPC run (run program after compile)

2017-01-21 Thread Lars
On Mon, January 16, 2017 1:21 pm, Lars wrote:
..
> On Mon, January 16, 2017 3:59 am, Sven Barth wrote:
>> No, FPC is a compiler, not a "runner" or debugger. That would even be
>> one of the few points where patches would *not* be welcome.
>>
>
> fpcrun.exe is an alternative to "fpc run"
>
> fpcrun.exe is trivial, and I can copy it into my fpc directory.. but
> wondered if others needed it.

trivial indeed...

https://github.com/z505/fpcRun

Project started on github. Tested to work on Windows.

Now I just have to try Unix, as, executeprocess works slightly different
on that system and some absolute path configuration to fpc might be
needed.

So basically FPCRUN.EXE project is now known as fpr.exe... as fpr is
easier to type at the command line for the lazy
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Language constructs and types that dependent upon system unit

2017-01-21 Thread Lars
Forgot to mention,  you can also write your own system unit and swap it in
place (in delphi and fpc).  You can modify existing system unit or even
rewrite your own system unit from scratch..

KOL/mck project does this sort of thing to decrease executable size to a
miniature size. Embedded programmers sometimes write their own system unit
too, for size constraints or special situations on embedded systems.

So don't feel that you are limited to the system.pp unit that you are
provided with delphi for fpc, as you can modify it... or even rewrite it
from scratch (not for faint of heart, but Kol/mck does something like it)

On Thu, January 19, 2017 1:28 pm, gabor wrote:
> I was hoping that maybe there is an easy answer. But I understand.
> Thanks.
>
>
> Michał.
>
>
> W dniu 2017-01-19 o 20:28, Jonas Maebe pisze:
>
>> It is therefore not possible to give an answer to your question that is
>>  generally valid. Furthermore, the answer could become wrong at any
>> time because all of that is implementation-dependent.
>>
>>
>> Jonas
>>
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

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


Re: [fpc-pascal] FPC run (run program after compile)

2017-01-22 Thread Lars
On Sat, January 21, 2017 11:54 pm, I previously wrote:
> https://github.com/z505/fpcRun
>
>
> Project started on github. Tested to work on Windows.
>
>
> Now I just have to try Unix, as, executeprocess works slightly different
> on that system and some absolute path configuration to fpc might be needed.
>

Solution was to use fpSystem instead of ExecuteProcess on unix, and use
ExecuteProcess on Windows

fpr or FPCRUN project seems to work good so far on linux and windows now.

Bsd/macos I have not tested
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] TProcess vs RunProcess()

2017-01-28 Thread Lars
On Thu, January 26, 2017 7:28 am, Michael Van Canneyt wrote:
>

>
> On Thu, 26 Jan 2017, Graeme Geldenhuys wrote:
>
>
>> Hi,
>>
>>
>> Whats the differences or pros and cons between using TProcess vs
>> RunProcess().
>>
>
> TProcess gives you full access to the process. You can kill it,
> pause it, write to stdin, read from stdout.
>
> These things cannot be done with RunProcess.
> That's one-shot and wait till it exits.
>

Similar to FpSystem() and ExecuteProcess, and then there is AssignStream
but assignstream/fpsystem unix only

http://www.freepascal.org/docs-html/rtl/sysutils/executeprocess.html

http://www.freepascal.org/docs-html/rtl/unix/assignstream.html

http://www.freepascal.org/docs-html/rtl/unix/fpsystem.html

I like fpsystem because it does not require absolute paths to commands,
too bad fpsystem not available on Windows.

All the above is used in webcmd (part of powtils) and also fpcRun ;-)

But I may try RunProcess/TProcess soon!
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] TProcess vs RunProcess()

2017-01-29 Thread Lars
On Fri, January 27, 2017 10:24 am, Graeme Geldenhuys wrote:
> On 2017-01-26 14:28, Michael Van Canneyt wrote:
>
>> TProcess gives you full access to the process. You can kill it,
>> pause it, write to stdin, read from stdout.
>>
>> These things cannot be done with RunProcess.
>> That's one-shot and wait till it exits.
>>
>
> Another difference simply so others might learn from this discussion
> (like I did).
>
>
> If you have a huge list of parameters, RunProcess() - at least under
> Windows - will most likely hit a 260 character limit, and then fail to
> actually execute. I don't actually know where that 260 limit originates
> from (Windows API, Command Prompt, FPC etc).
>

One issue I discovered with ExecuteProcess, and fpSystem, is I cannot
figure out a way to capture StdErr... TProcess likely has more control
over this. Tried

Assign(StdErr, 'somefile.txt')
Rewrite(StdErr)

And didn't seem to work

So if you run a process and nothing prints to stdout, and there is some
data printed to stderr, I do not know how to capture it. Which makes me
want to try TProcess instead, but if I could do it with FpSystem and
ExecuteProcess that would be nice
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] ppcjvm issues

2017-01-29 Thread Lars
On Fri, January 27, 2017 11:37 am, Dmitry Boyarintsev wrote:
> On Fri, Jan 27, 2017 at 12:52 PM, Jon Foster
> 
> wrote:
>
>
>> Correct me if I'm wrong: It would seem like that your free
>> implementation
>>> doesn't actually do anything, other than fulfilling the obligation of
>>>  having a "free". If I do this:
>>>
>>
>> var o: TObject;
>> begin o:=TObject.create;
>> { do something ... }
>> o.free; end.
>>
>> Wouldn't "o" still contain a reference after "free" is called? In
>> non-JVM FPC "self" is just another variable, who's origin is somewhat
>> hidden by the compiler. The call to "o.free" would do something like
>> "TObject.free(o)"
>> where "o" is passed by *value* into the procedure variable "self".
>> "Self"
>> comes and goes with the scope of the "TObject.free" procedure. Which is
>> why if I'm concerned about detecting whether or not "o" still contains a
>>  correct object reference I would need to do something like this:
>> "o.free;
>> o:=nil;" so I can test for "nil" later. Although I think FPC added a
>> procedure to do that some time back. Yup, I see it
>> "SysUtils.FreeAndNil".
>>
>>
>> I'm not sure of the specific semantics of the JVM calls but from what I
>>  read in the various FPC JVM related pages on the wiki it would seem to
>> use similar semantics.
>
>
> Object Pascal semantic of calling .Free suggests that "o" would no longer
>  be a valid object. If a dummy Free method is available for JVM, then such
> semantic is violated.
>
> However, if JVM free method would at least reset "o" reference to nil,
> then the semantic of "o" being an invalid object remains.
>
> It also suggests to the garbage collector that the memory could be
> recycled earlier, that the variable leaves the scope.
>
> thanks, Dmitry

Another interesting idea, from all this discussion, is whether a mixed
Garbage Collected/Manually Collected language could exist.

Imagine a garbage collected programming language, that at any point in
time, you could take control of with your bare hands and free anything.

This, likely, would be:
1) a bad idea
2) hard to implement
3) or an interesting thesis project for some ivory tower...

I'm not sure if this sort of what Delphi's iOS fake free/release system
allows...

I dream of a language that is garbage collected for every day use (most
projects) but when I want to have real time control (nuclear power plant
or rocket ship that requires code run in real time), this dream language
could be handy.

It could also be a confusing nightmare (as Delphi iOS garbage
collection/fake release system is getting a bit scary)
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Pipe vs Memory buffer.

2017-01-29 Thread Lars
On Fri, January 27, 2017 7:54 am, fredvs wrote:
>
> I am not sure that a array of byte is what op_test_memory want.
> It is not a pipe (like lot of other audio lib use), if it is not a array
> of byte, what does he want...?
>


C doesn't even really have arrays since it is so low level (well this is
disputed). Often an API function that accepts a buffer could allow
multiple types of buffers, that you allocate yourself... Make sure the
function doesn't modify the buffer size (bad api practice) and make you
allocate the memory

It just seems like this is similar to windows API programming where the
windows C api would allow a fixed array of byte (or similar), or your own
allocated heap array i.e. whatever you want.

Advantage of heap array is you can change it; fixed static stack array is
fixed and not modifiable on heap... But make sure the api doesn't muck
with the buffer on it's end or try to allocate memory for it, as that
should be your job. But you never know with some api's. This should all be
in their docs? They don't have proper docs?

But I know nothing of Opus, sorry. (and can you look into the actual
source code of opus or is this closed source?)
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] ppcjvm issues

2017-01-29 Thread Lars
On Fri, January 27, 2017 10:52 am, Jon Foster wrote:
>

> On 01/27/2017 06:36 AM, Dmitry Boyarintsev wrote:
>
>> On Tue, Jan 10, 2017 at 6:14 AM, Michael Schnell > > wrote:
>>
>>
>>
>> If destroying an object is not necessary, the class should provide a
>> dummy Free procedure. So the application programmer always can/should use
>> Free.
>>
>>
>> Why dummy? if it should be like this
>>
>>
>> procedure TObject.Free; begin if Self<>nil then Self:=nil; end;
>>
>> Destroying object is not necessary, but dereferencing is.
>> If the code keeps the reference to an object, it would not be collected.
>>  [...]
>>
> Correct me if I'm wrong: It would seem like that your free implementation
>  doesn't actually do anything, other than fulfilling the obligation of
> having a "free".

That's kind of the point, you aren't actually really freeing the object
but emulating something a close as you could get to it... Delphi iOS
release/free fake/dummy system does something similar.

But, it's really confusing, as you have to think about what the hell
consequences all this causes.

For example see:
http://stackoverflow.com/questions/27818697/how-to-free-a-component-in-android-ios

"DisposeOf breaks ARC. It violates golden rule of ARC Any object reference
can be either valid object reference or nil and introduces third state -
disposed "zombie" object reference.

Anyone trying to understand ARC memory management should look at DisposeOf
like addition that just solves Delphi specific framework issues and not
concept that really belongs to ARC itself. "

"Why DisposeOf exists in Delphi ARC compilers?

TComponent class (and all its descendants) was designed with manual memory
management in mind. It uses notification mechanism that is not compatible
with ARC memory management because it relies on breaking strong reference
cycles in destructor. Since TComponent is one of base classes Delphi
frameworks rely upon, it must be able to function properly under ARC
memory management. "
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Pipe vs Memory buffer.

2017-01-29 Thread Lars
On Sun, January 29, 2017 6:04 am, José Mejuto wrote:
> El 28/01/2017 a las 13:32, fredvs escribió:
>
>
>> TOpusFileCallbacks = record
>> read: op_read_func;
>> seek: op_seek_func;
>> tell: op_tell_func;
>> close: op_close_func;
>> end;
>>
>> This does not work:
>>
>>
>> HandleOP := op_test_callbacks(pointer(InPipe),op_callbacks,
>> BufferURL[0],
>> PipeBufferSize, err);
>>
>>
>
> Hello,
>
>
> As you need to use records you should specify {$PACKRECORDS C} or you
> could get a different record layout than C expects.
>
> --

Doesn't some C compilers pack records differently, so packrecords is only
compatiable with GNU c compiler but some other compiler could do it
differently? Sorry I don't know
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] TProcess vs RunProcess()

2017-01-29 Thread Lars
On Sun, January 29, 2017 1:36 pm, Santi wrote:

>  Maybe ExecuteProcess is calling some kind of shell,
> Freepascal developers will tell.
>


To call the shell you send in cmd /C

FpSystem does this, but it's on unix

Calling the shell is useful for not requiring absolute paths to
commands... which is why I like fpSystem...

And to call a dos command you need a shell like cmd /C because calling a
dos command won't do anything, it's not an exe (there is no DIR.exe file
for example AFAIK).. so to call DIR (same as LS on unix) you need to
invoke a shell.


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


Re: [fpc-pascal] Pipe vs Memory buffer.

2017-01-29 Thread Lars
On Sun, January 29, 2017 4:45 am, fredvs wrote:
> Hello Lars.
>
>
> Thanks for your brilliant light.
>
>
>> (and can you look into the actual source code of opus or is this closed
>>  source?)
>
> ==> https://github.com/xiph/opus
>


Well the function you were using with a buffer is here:

https://github.com/xiph/opusfile/search?utf8=%E2%9C%93&q=op_test_memory

in src/opusfile.c

OggOpusFile *op_test_memory(const unsigned char *_data,size_t _size,
 int *_error){
OpusFileCallbacks cb;
return
op_test_close_on_failure(op_mem_stream_create(&cb,_data,_size),&cb,
   _error);
}

So it calls op_mem_stream_create which is:
https://github.com/xiph/opusfile/search?utf8=%E2%9C%93&q=op_mem_stream_create&type=Code

in src/stream.c

void *op_mem_stream_create(OpusFileCallbacks *_cb,
 const unsigned char *_data,size_t _size){
  OpusMemStream *stream;
  if(_size>OP_MEM_SIZE_MAX)return NULL;
  stream=(OpusMemStream *)_ogg_malloc(sizeof(*stream));
  if(stream!=NULL){
*_cb=*&OP_MEM_CALLBACKS;
stream->data=_data;
stream->size=_size;
stream->pos=0;
  }
  return stream;
}


Thanks to github's cool web gui you can find code pretty fast and share
where code is with developers, compared to if it was on your hard drive
you could not "share your hard drive" unless you were on emule or vnc ;-)
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] TProcess vs RunProcess()

2017-01-29 Thread Lars
On Sun, January 29, 2017 2:41 pm, Marco van de Voort wrote:
> Some likely scenarios (e.g. run and capture stdout) have been prepared in
>  RunCommand, also in unit Process.
>
>
> The main motivation for adding these is that 90+% of the TProcess and
> CreateProcess usage in the forums was faulty (specially for larger outputs
>  or when the process also printed a lot on stderr (thanks Pierre!)).
>

So people were having issues with stderr going crazy (lots of prints to
stderr)?

And this is the problem I have with executeprocess: I want the results
from stderr, and need them, but can't figure out how to access them.. only
stdout is what I retrieve writes from.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] TProcess vs RunProcess()

2017-01-29 Thread Lars
On Sun, January 29, 2017 10:46 am, Graeme Geldenhuys wrote:
> On 2017-01-29 07:59, Lars wrote:
>
>> So if you run a process and nothing prints to stdout, and there is some
>>  data printed to stderr, I do not know how to capture it. Which makes
>> me want to try TProcess instead
>
>
> Indeed, that is one of the big differences between TProcess and
> ExecuteProcess. I use TProcess often to execute something and then
> capture the output results.  fpGUI's example IDE (Maximus) shows how it
> can be done with TProcess.

Well I may modify executeprocess/fpsystem to deal with stderr if that is a
missing feature (may not be possible, haven't looked into it much).

Or, get assignstream working on windows and not just unix, but that will
be a bit of a big undertaking, and again may not be possible.

mseide/msegui may also have some tips in its source code as it captures a
lot of stuff and puts it into the ide in its custom widgets that trap
outputs, actually kind of a bit like a Blackbox ComponentPascal IDE from
switzerland, but still different ;-)

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


Re: [fpc-pascal] TProcess vs RunProcess()

2017-01-29 Thread Lars
On Sun, January 29, 2017 3:18 am, Marco van de Voort wrote:
> In our previous episode, Lars said:
>
>> Assign(StdErr, 'somefile.txt')
>> Rewrite(StdErr)
>>
>>
>> And didn't seem to work
>>
>>
>> So if you run a process and nothing prints to stdout, and there is some
>>  data printed to stderr, I do not know how to capture it. Which makes
>> me want to try TProcess instead, but if I could do it with FpSystem and
>> ExecuteProcess that would be nice
>>
>
> Executeprocess doesn't support piping. It orignally was mainly meant as a
>  portable dos.exec with parameters passed separately and without string
> length limits, implementable on RTL level.

But doesn't all processes report to stderr?
Ones that are created in a program do not report to stderr?

The OS makes it optional if you want to report to stderr?  Interesting..

Another idea is to modify AssignStream to work on windows as AFAIK it only
works on unix from the unix units of rtl..

Quote:
function AssignStream(var StreamIn, StreamOut, StreamErr: Text; const
prog: String): LongInt;
{
  Starts the program in 'prog' and makes its input, output and error output
  the other end of three pipes, which are the stdin, stdout and stderr of a
  program specified in 'prog'.

^^^ very useful function!

Reason I want to avoid TProcess is simply because cgi programs being
around 30-100K are easier to upload for people with limited internet
connection speeds. As soon as I pull in large units that involve lots of
classes the cgi programs become over 200-500K.

However I will use tprocess if it's a time save, which indeed it is
instead of rewriting assignstream for windows.

Plus, golang cgi exe's are about 2MB in size, so golang ain't got anything
on fpc at this moment (fpc still creates small programs compared to GoLang
runtime programs!)
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Pointer hashing

2017-01-29 Thread Lars
On Sun, January 29, 2017 7:37 pm, Ryan Joseph wrote:
> I'm trying to hash a pointer value and found some example of hash
> function but not sure about translations and the process in general.
...

> x := (Power((x shr 16), x)) * $45d9f3b; x := Power((x shr 16), x);
result :=


The math unit, is something I've been meaning to try ... don't have much
experience with it.. but did you try the power operator?

It's **

  x := ((x shr 16) ** x) * $45d9f3b;

Above code please do not trust it, I have no experience with operator
overloading (or very little). I did not check to see what the function
does, is, etc.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] Operator overloading with Text labels or words

2017-01-29 Thread Lars
It's not possible to define an operator like:

Operator AbcXyz(r : real; z1 : complex) z : complex;
begin
end;

Is it?

Has to be a symbol?

If one could use words or text as operators this might be very
interesting, although, probably a double edged sword like Lisp where you
could embed programming languages inside programming languages.

For example:

  x := 4 PLUS 4;
  writeln(x);

Prints 8..


Operator Plus(...);
begin
end;

So you just invented Cobol inside fpc or something like cobol. Bad example..
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] TProcess vs RunProcess()

2017-01-30 Thread Lars
On Mon, January 30, 2017 12:57 am, Marco van de Voort wrote:
>
>> Or, get assignstream working on windows and not just unix, but that
>> will be a bit of a big undertaking, and again may not be possible.
>
> Again, duplicating TProcess.
>

Except assignstream doesn't require TProcess.Create and Free and uses old
school programming, which, for some reason, I'm addicted to. Maybe just
stuck in 1970's even though I was born in 1980s
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] TProcess vs RunProcess()

2017-01-30 Thread Lars
On Mon, January 30, 2017 1:06 am, Marco van de Voort wrote:
>> Reason I want to avoid TProcess is simply because cgi programs being
>> around 30-100K are easier to upload for people with limited internet
>> connection speeds. As soon as I pull in large units that involve lots
>> of classes the cgi programs become over 200-500K.
>
> Yes. And they might fit on one side of a 5.25" inch dd floppy too! Yeah,
> let's party like it's 1999!


You don't seem to understand the concept of RAD web development ;-)

If it takes me 2 minutes to upload a massive 2mb cgi program through FTP,
since I pay half price for my internet connection for half speed
DSL/Cable.. That's not rad.

Sometimes I develop a cgi program and upload it every few minutes, so
waiting 1-2 minutes for a cgi to upload with total commander is just
pathetic.

Uploading a 50kb or 30kb cgi is where it is at.

I live in a first world country but in third world countries with dial up
or whatever slow dsl they use, I can imagine a 2MB golang cgi (or lazarus
zeos/classes/other cgi) taking more than 2 minutes. That's not RAD

Just try compling some hello world or simple programs in lazarus and
imagine they take 2 minutes to compile. That's what C++ compilers do.  If
you are a c++ fan I guess 2MB/2minute upload cgi programs are
satisfactory...

Some of us do RAD cgi programming where everything is instant.

Good for you living in a country where dsl/cable is very fast and you
don't care about FTP upload times.  I think they call that being spoiled,
or being white or something.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] for loop vs while loop

2017-02-02 Thread Lars
On Wed, February 1, 2017 4:49 am, Graeme Geldenhuys wrote:
> Hi,
>
>
> Just curious (been in a discussion with somebody else). Is there a
> performance difference between a FOR loop and a WHILE loop?
>
> Not sure if it will make a difference, but the usage is with three
> nested loops, iterating over some 300,000 plus data points in total.
>
>
> Regards,
> Graeme
>

Don't forget Repeat Until...

Simply look at the assembler code generated (a big sin)

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


Re: [fpc-pascal] uses myunit in '../src/myunit.pas' ?

2017-02-11 Thread Lars
On Sat, February 11, 2017 5:56 am, Fred van Stappen wrote:
>
> Unit names are considered to be unique, so strictly, for the compiler
> there is no need to specify the path explicitly in code when the unit path
> is given to the compiler when calling it from the command line.
>
> To do this, use the -Fu parameter when calling fpc to include ../src to
> the unit path.
>
> Greetings,
> Tim Veldhuizen.
>
>

I have found some use cases for hard coded paths in the source files..
although these use cases are rare. I think even delphi main project DPR
file does this, if I remember correctly, but I found other uses cases
other than that.  One example might be when you are writing a quick
program and don't want to send in a whole bunch of -Fu options and go into
dialog boxes in lazarus configuring it, so you just quickly write it in
your program ../someunit instead of configuring -Fu which can be obnoxious
and tedious.. But that's just one use case. Another use case, AFAIR was a
build system instead of gnu make.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] sqldb create/free lifetime of object

2017-04-12 Thread Lars
The sql query object and transaction object are created but not freed:

http://www.freepascal.org/docs-html/fcl/sqldb/usingsqldb.html

I think the docs should mention that the objects need not to be freed, as
this violates normal programming practice of freeing all objects you
create.

P.s. how is it freed magically? Sorry I am on cell phone and cannot look
at source easily to find out

This is one gripe I have with programming is that you never really know if
something should be freed just by looking at the code. If it is not freed
and it was created by you it is a good indication its a mem leak, but not
if there is magic behind the scenes to free it automatically
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

  1   2   >