[fpc-pascal] Unicode function names

2011-10-20 Thread Mark Morgan Lloyd
Out of curiosity, I've just tried creating a function named ⍳ (Unicode 
character 2373, i.e. the APL iota function). FPC trunk complains


Fatal: illegal character "'�'" ($E2)

What is the rule here- functions must be entirely ANSI or functions must 
start with ANSI?


--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Unicode function names

2011-10-20 Thread michael . vancanneyt



On Thu, 20 Oct 2011, Mark Morgan Lloyd wrote:

Out of curiosity, I've just tried creating a function named ⍳ (Unicode 
character 2373, i.e. the APL iota function). FPC trunk complains


Fatal: illegal character "'???'" ($E2)

What is the rule here- functions must be entirely ANSI or functions must 
start with ANSI?


To my knowledge FPC does not support non-ascii identifiers ?
Only a-z, 0-9 and _ are allowed.

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

Re: [fpc-pascal] Unicode function names

2011-10-20 Thread Sven Barth

Am 20.10.2011 10:04, schrieb michael.vancann...@wisa.be:



On Thu, 20 Oct 2011, Mark Morgan Lloyd wrote:


Out of curiosity, I've just tried creating a function named ⍳ (Unicode
character 2373, i.e. the APL iota function). FPC trunk complains

Fatal: illegal character "'???'" ($E2)

What is the rule here- functions must be entirely ANSI or functions
must start with ANSI?


To my knowledge FPC does not support non-ascii identifiers ?
Only a-z, 0-9 and _ are allowed.


Yes, Michael is right. Only the ASCII characters a-z, A-Z, 0-9 and _ are 
allowed. There was no change in FPC what identifiers it understands.

I personally wouldn't mind if that stay ASCII...

Regards,
Sven

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


Re: [fpc-pascal] Unicode function names

2011-10-20 Thread Mark Morgan Lloyd

Sven Barth wrote:

Am 20.10.2011 10:04, schrieb michael.vancann...@wisa.be:



On Thu, 20 Oct 2011, Mark Morgan Lloyd wrote:


Out of curiosity, I've just tried creating a function named ⍳ (Unicode
character 2373, i.e. the APL iota function). FPC trunk complains

Fatal: illegal character "'???'" ($E2)

What is the rule here- functions must be entirely ANSI or functions
must start with ANSI?


To my knowledge FPC does not support non-ascii identifiers ?
Only a-z, 0-9 and _ are allowed.


Yes, Michael is right. Only the ASCII characters a-z, A-Z, 0-9 and _ are 
allowed. There was no change in FPC what identifiers it understands.

I personally wouldn't mind if that stay ASCII...


I agree, I was only experimenting on a whim. I think possibly that error 
message could be improved though, since by the time it was output it had 
been translated to a "I don't know what this is" blob and even the 
numeric representation was lost.


--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


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

2011-10-20 Thread Andrew Pennebaker
2.6, eh? Awesome.

I'm using the SVN trunk, but it's not working for me for some reason. I'll
just wait for v2.6 then.

Cheers,

Andrew Pennebaker
www.yellosoft.us

On Thu, Oct 20, 2011 at 2:19 AM, Sven Barth wrote:

> Am 19.10.2011 20:08, schrieb Andrew Pennebaker:
>
>  Right, I tried just {$mode delphi} and just generic, and when both
>> failed I tried them at the same time.
>>
>> Maybe I'm not using a recent enough version?
>>
>> Free Pascal Compiler version 2.4.4 [2011/05/01] for i386
>>
>
> That's why I said "trunk". Trunk is the development version of the
> compiler. You can look for compiler snapshots on the FPC website (look at
> the Development page). Also you can download the sources of the compiler and
> compile them using your existing 2.4.4 compiler.
> Another possibility is to wait until the 2.6 release is released. That will
> contain the features as well.
>
>
> Regards,
> Sven
>
> __**_
> 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] Re: Delphi's anonymous functions in Free Pascal

2011-10-20 Thread Gregory M. Turner
- Original Message -
> Am 19.10.2011 20:23, schrieb Andrew Pennebaker:
> > Practical uses for referencable anonymous functions:
> 
> For such applications one uses procedure variables in pascal.
> 

> > (map (lambda (x) (+ x 1)) '(1 2 3))
> > 
> > -> (2 3 4)

[snip!]

> I still don't see why this cannot be done by procedure variables: one
> can easily pass a procedure reference to a compare function to any
> sort
> library call. The example is far from explaining why it is needed to
> be
> able to return a reference to an anonymous method to the outside of
> the
> enclosing function.

[not_sure_if_serious.png]

Interesting discussion -- at least for me, I didn't know Delphi had this 
feature.

In case anyone really doesn't see the point, consider that this thing:

  http://www.youtube.com/watch?v=cYw2ewoO6c4

has all the capabilities of Object Pascal (with less flowery syntactic sugar to 
mess up the purity of the system).

:P

--
Greg Turner

P.S., hello, list!

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


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

2011-10-20 Thread Florian Klämpfl
Am 20.10.2011 21:09, schrieb Gregory M. Turner:

> 
> Interesting discussion -- at least for me, I didn't know Delphi had this 
> feature.
> 
> In case anyone really doesn't see the point, consider that this thing:
> 
>   http://www.youtube.com/watch?v=cYw2ewoO6c4
> 
> has all the capabilities of Object Pascal (with less flowery syntactic sugar 
> to mess up the purity of the system).

If anybody does not see why increasing complexity without a good reason
should be avoided, I recommend:

http://www.youtube.com/watch?v=kYUrqdUyEpI
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


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

2011-10-20 Thread Gregory M. Turner


- Original Message -
> Am 20.10.2011 21:09, schrieb Gregory M. Turner:
>
> > In case anyone really doesn't see the point, consider that this
> > thing:
> > 
> >   http://www.youtube.com/watch?v=cYw2ewoO6c4
>
> If anybody does not see why increasing complexity without a good
> reason
> should be avoided, I recommend:
> 
> http://www.youtube.com/watch?v=kYUrqdUyEpI

:)

Good point.  I guess nothing's O(free lunch).

-- 

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


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

2011-10-20 Thread Juha Manninen
2011/10/20 Florian Klämpfl 

> If anybody does not see why increasing complexity without a good reason
> should be avoided, I recommend:
>
> http://www.youtube.com/watch?v=kYUrqdUyEpI
>


:-)

There is lots of confusion about anonymous functions. The name is
misleading, they are called closures in other languages.
There was a similar discussion earlier, see :
http://www.hu.freepascal.org/lists/fpc-pascal/2010-January/023755.html

The origin is from functional languages but it is fine to borrow it to OP,
the same way classes and object features were borrowed earlier from other
languages. Besides I think the closure addition is almost as important.

They have some very important uses, like making multithreading easier.
I copy text from Delphi help page again here because it looks so cool:

-
Using Code for a Parameter

Anonymous methods make it easier to write functions and structures
parameterized
by code, not just values.

Multithreading is a good application for anonymous methods. if you
want to execute
some code in parallel,
you might have a parallel-for function that looks like this:

type
TProcOfInteger = reference to procedure(x: Integer);

procedure ParallelFor(start, finish: Integer; proc: TProcOfInteger);

The ParallelFor procedure iterates a procedure over different threads.

Assuming this procedure is implemented correctly and efficiently using
threads
or a thread pool, it could then be easily used to take advantage of multiple
processors:

procedure CalculateExpensiveThings;
var
results: array of Integer;
begin
SetLength(results, 100);
ParallelFor(Low(results), High(results),
procedure(i: Integer) // \
begin // \ code block
results[i] := ExpensiveCalculation(i); // / used as parameter
end // /
);
// use results
end;

Contrast this to how it would need to be done without anonymous methods:
probably a "task" class with a virtual abstract method, with a concrete
descendant for ExpensiveCalculation, and then adding all the tasks to a
queue--not nearly as natural or integrated.

Here, the "parallel-for" algorithm is the abstraction that is being
parameterized by code. In the past, a common way to implement this pattern
is
with a virtual base class with one or more abstract methods; consider the
TThread class and its abstract Execute method. However, anonymous methods
make
this pattern--parameterizing of algorithms and data structures using
code--far
easier.

Regards,
Juha Manninen
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

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

2011-10-20 Thread Juha Manninen
2011/10/20 Gregory M. Turner 

> Good point.  I guess nothing's O(free lunch).
>

Yes, the downside here is that the concept is very different from any syntax
in OP. It will be difficult to learn properly.

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

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

2011-10-20 Thread Florian Klämpfl
Am 20.10.2011 22:31, schrieb Juha Manninen:
> 
> They have some very important uses, like making multithreading easier.
> I copy text from Delphi help page again here because it looks so cool:

The same can be done with fpc (nested if needed) procedure variables and
it will be more readable (imo)? The example still does not take
advantage of properties of anonymous methods/closurs which cause
complexity like being ref. counted, putting locals on the heap etc.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


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

2011-10-20 Thread Andrew Pennebaker
It's inconsistent and ripe for bugs.

Cheers,

Andrew Pennebaker
www.yellosoft.us
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

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

2011-10-20 Thread Andrew Haines
On 10/20/11 17:43, Andrew Pennebaker wrote:
> It's inconsistent and ripe for bugs.
> 
> Cheers,
> 
> Andrew Pennebaker
> www.yellosoft.us 
> 
> 
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
As far as I know it's historical. String[0] used to contain the string
length (255 max). Now it may be something else.

Regards,

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


[fpc-pascal] Format() directives

2011-10-20 Thread Andrew Pennebaker
In the future, could Format respect the difference between '%x' and '%X'?
It's useful to use the former for lowercase hexadecimal.

Cheers,

Andrew Pennebaker
www.yellosoft.us
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

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

2011-10-20 Thread Tomas Hajny
On 20 Oct 11, at 17:43, Andrew Pennebaker wrote:

> It's inconsistent and ripe for bugs.

Array indices may start at any ordinal value (including e.g. 
characters, values of enumerated types, etc.), not just 0. Only 
dynamic arrays always start at 0 because that is how they have been 
"imported" from other languages.

Tomas

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


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

2011-10-20 Thread waldo kitty

On 10/20/2011 11:08, Andrew Pennebaker wrote:

2.6, eh? Awesome.

I'm using the SVN trunk, but it's not working for me for some reason.


this is why the latest version of the compiler, 2.4.4 is the one supported ;)


I'll just wait for v2.6 then.


always another possibility... depending on the waittime, of course ;)
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


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

2011-10-20 Thread waldo kitty

On 10/20/2011 15:17, Florian Klämpfl wrote:

Am 20.10.2011 21:09, schrieb Gregory M. Turner:



Interesting discussion -- at least for me, I didn't know Delphi had this 
feature.

In case anyone really doesn't see the point, consider that this thing:

   http://www.youtube.com/watch?v=cYw2ewoO6c4

has all the capabilities of Object Pascal (with less flowery syntactic sugar to 
mess up the purity of the system).


If anybody does not see why increasing complexity without a good reason
should be avoided, I recommend:

http://www.youtube.com/watch?v=kYUrqdUyEpI


+1~

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


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

2011-10-20 Thread waldo kitty

On 10/20/2011 16:35, Juha Manninen wrote:

2011/10/20 Gregory M. Turner mailto:g...@malth.us>>

Good point.  I guess nothing's O(free lunch).

Yes, the downside here is that the concept is very different from any syntax in
OP. It will be difficult to learn properly.


i still fight, today, with much of my LISP code... :? :(
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal



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

2011-10-20 Thread waldo kitty

On 10/20/2011 17:43, Andrew Pennebaker wrote:

It's inconsistent and ripe for bugs.


funny thing, that... i thought the same thing when looking at the proposals and 
requests :LOL:

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


Re: [fpc-pascal] Format() directives

2011-10-20 Thread waldo kitty

On 10/20/2011 17:47, Andrew Pennebaker wrote:

In the future, could Format respect the difference between '%x' and '%X'? It's
useful to use the former for lowercase hexadecimal.


please forgive the stoopid question but, is there any real difference? in hex, 
f00 is the same as F00, isn't it??

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


Re: [fpc-pascal] Format() directives

2011-10-20 Thread Andrew Pennebaker
Correct. But some systems expect hex input in lowercase, and some expect it
in uppercase. It would be nice if Format('%x', [s]) and Format('%X', [s])
allowed this kind of customization.

For now, AnsiLowerCase(Format('%X', [s]) is a workaround.

Cheers,

Andrew Pennebaker
www.yellosoft.us

On Thu, Oct 20, 2011 at 8:28 PM, waldo kitty wrote:

> On 10/20/2011 17:47, Andrew Pennebaker wrote:
>
>> In the future, could Format respect the difference between '%x' and '%X'?
>> It's
>> useful to use the former for lowercase hexadecimal.
>>
>
> please forgive the stoopid question but, is there any real difference? in
> hex, f00 is the same as F00, isn't it??
> __**_
> 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] Re: Delphi's anonymous functions in Free Pascal

2011-10-20 Thread Andrew Pennebaker
If anybody does not see why increasing complexity without a good reason
should be avoided, I recommend:

http://www.youtube.com/watch?v=kYUrqdUyEpI

Lisp used for nuclear fail-safe
systems.
I doubt languages without *map* are up to the job.

Cheers,

Andrew Pennebaker
www.yellosoft.us

On Thu, Oct 20, 2011 at 3:17 PM, Florian Klämpfl wrote:

> Am 20.10.2011 21:09, schrieb Gregory M. Turner:
>
> >
> > Interesting discussion -- at least for me, I didn't know Delphi had this
> feature.
> >
> > In case anyone really doesn't see the point, consider that this thing:
> >
> >   http://www.youtube.com/watch?v=cYw2ewoO6c4
> >
> > has all the capabilities of Object Pascal (with less flowery syntactic
> sugar to mess up the purity of the system).
>
> If anybody does not see why increasing complexity without a good reason
> should be avoided, I recommend:
>
> http://www.youtube.com/watch?v=kYUrqdUyEpI
> ___
> 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] Re: Delphi's anonymous functions in Free Pascal

2011-10-20 Thread Jürgen Hestermann

Florian Klämpfl schrieb:
> If anybody does not see why increasing complexity without a good reason
> should be avoided, I recommend:

I agree wholeheartly. In the past Pascal was a simple still powerfull 
language but meanwhile it has become a catchment tank for all features 
of all other languages. This defeats the original intention of Nicholas 
Wirth and the reason for what I love(d) the language. It seems everybody 
tries to mimic Pascal into whatever he is used to do in other languages. 
So we should no longer call this (Object) Pascal but "Chimera".

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


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

2011-10-20 Thread Roberto P.
2011/10/21 Tomas Hajny 

> On 20 Oct 11, at 17:43, Andrew Pennebaker wrote:
>
> > It's inconsistent and ripe for bugs.
>
> Array indices may start at any ordinal value (including e.g.
> characters, values of enumerated types, etc.), not just 0. Only
> dynamic arrays always start at 0 because that is how they have been
> "imported" from other languages.
>
> Tomas
>
>
As said by Thomas, I think we will have to get along with string[1].
However, since I stumbled upon the string[0] mistake more than once, I take
the chance to suggest a way to reduce the likelihood of it.

During compilation, by statically checking the indices used to access the
string, the compiler could fire a warning (or error?) if a  string[0] is
found.
I think that most of the times the string[0] happens inside a for loop or
similar, so a good percentage of these mistakes can be caught.

R#


> ___
> 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] Re: Delphi's anonymous functions in Free Pascal

2011-10-20 Thread Florian Klaempfl
Am 21.10.2011 03:49, schrieb Andrew Pennebaker:
> 
> Lisp used for nuclear fail-safe systems
> I doubt languages without /map/ are up to the job.


Great, why don't you continue to use lisp then? If pascal does not
offers the language concepts you are used to, pascal is the wrong
language for you.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


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

2011-10-20 Thread Juha Manninen
2011/10/21 Jürgen Hestermann 

> Florian Klämpfl schrieb:
>
> > If anybody does not see why increasing complexity without a good reason
> > should be avoided, I recommend:
>
> I agree wholeheartly. In the past Pascal was a simple still powerfull
> language but meanwhile it has become a catchment tank for all features of
> all other languages. This defeats the original intention of Nicholas Wirth
> and the reason for what I love(d) the language. It seems everybody tries to
> mimic Pascal into whatever he is used to do in other languages. So we should
> no longer call this (Object) Pascal but "Chimera".
>

Please look at some old Pascal code from 80's. Lots of shortstring
manipulation with pointers. Very much comparable to C, and as prone to
errors as C.
It is good to realize that Pascal would have died already without the
class/object additions made by Borland.
The challenge is to add only the RIGHT features. In school I must study
again C++ and they clearly did it wrong. Uhhh!
IMO the OP additions have been good so far. For example generics containers
eliminate ugly type-casts. It is an improvement, clearly.

Closures seem like a powerful thing which can improve code.
Now Florian mentioned that procedure variables could do the same thing. I
clearly don't understand the topic enough, I must learn more.

It is funny how fashion trends also affect the evolution of programming
languages.
When object oriented programming became a trend, everything had to be an
object.
Java libs are a good example. Some classes (nouns) have only one method
(verb) called "Execute".
Translated to human languages, it is like "man's walking executor executes"
instead of "man walks".

Now the functional languages turn fashionable, maybe as a counter-effect to
OO.
Some people said that programming became funny again when using a functional
language (Haskel was it?).
I also want to learn and understand how to say things with only functions
(verbs).

All this turbulence proves how young is the evolution of programming
languages. Human languages have a much longer evolution.
You can see they have a versatile syntax. They have lots of redundancy and
synonyms to ensure "error free message delivery".
The syntax (grammer) is not always simple but it is expressive.

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