Re: [fpc-pascal] a proposal about "with" syntax

2013-03-19 Thread Luca Olivetti
Al 18/03/13 04:11, En/na Paul Ishenin ha escrit: > '=' can't be used because it can be a part of expression. There is no > big difference between > with (a = SomeObject) do > and > with a = SomeObject do But since "with" is only for records/objects/classes there's no possible confusion (the resul

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-18 Thread Bart
On 3/18/13, Jürgen Hestermann wrote: > You won't cripple down all variables to one letter names A, B, C only > because this is easier to type, won't you? You would if you'ld be programming in MUMPS ;-) Bart ___ fpc-pascal maillist - fpc-pascal@lists

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-18 Thread Ralf A. Quint
At 10:03 AM 3/18/2013, Jürgen Hestermann wrote: Am 2013-03-16 07:13, schrieb Xiangrong Fang: I would like to do this: with MyClassInstance as mci, SomethingElse do begin Caption := 'A new caption'; for i := 0 to Count - 1 do mci[i] := UpperCase(mci[i]); end; That is, to add an optiona

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-18 Thread Jürgen Hestermann
Am 2013-03-16 07:13, schrieb Xiangrong Fang: I would like to do this: with MyClassInstance as mci, SomethingElse do begin Caption := 'A new caption'; for i := 0 to Count - 1 do mci[i] := UpperCase(mci[i]); end; That is, to add an optional "as" clause to the with statement so that access a

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-18 Thread Sven Barth
Am 18.03.2013 15:24, schrieb Flávio Etrusco: On Mon, Mar 18, 2013 at 10:42 AM, Sven Barth wrote: Am 18.03.2013 10:36 schrieb "Xiangrong Fang" : (...) I cannot recall if there is already a notion of "alias" in free pascal, if not then we just introduce this idea within the scope of "with" expre

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-18 Thread Flávio Etrusco
On Mon, Mar 18, 2013 at 10:42 AM, Sven Barth wrote: > Am 18.03.2013 10:36 schrieb "Xiangrong Fang" : > (...) >> I cannot recall if there is already a notion of "alias" in free pascal, if >> not then we just introduce this idea within the scope of "with" expression. > > Which is why I suggested "ab

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-18 Thread Sven Barth
Am 18.03.2013 10:36 schrieb "Xiangrong Fang" : > > 2013/3/18 Marco van de Voort >> >> In our previous episode, Xiangrong Fang said: >> > > In our previous episode, Xiangrong Fang said: >> > > > Alternatively, how about just use SPACE to separate the token? i.e.: >> > > > >> > > > with SomeObject o

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-18 Thread Mattias Gaertner
On Mon, 18 Mar 2013 15:36:13 +0800 Xiangrong Fang wrote: > Alternatively, how about just use SPACE to separate the token? i.e.: > > with SomeObject o1, SomeOtherObject o2 do I think this is a bad idea. One of the strengths of Pascal is its verbosity/redundancy which allows unambiguous error

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-18 Thread Xiangrong Fang
2013/3/18 Marco van de Voort > In our previous episode, Xiangrong Fang said: > > > In our previous episode, Xiangrong Fang said: > > > > Alternatively, how about just use SPACE to separate the token? i.e.: > > > > > > > > with SomeObject o1, SomeOtherObject o2 do > > > > > > That's perfectly

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-18 Thread Marco van de Voort
In our previous episode, Xiangrong Fang said: > > In our previous episode, Xiangrong Fang said: > > > Alternatively, how about just use SPACE to separate the token? i.e.: > > > > > > with SomeObject o1, SomeOtherObject o2 do > > > > That's perfectly fine for C. But this isn't C. > > What's wro

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-18 Thread Xiangrong Fang
2013/3/18 Marco van de Voort > In our previous episode, Xiangrong Fang said: > > Alternatively, how about just use SPACE to separate the token? i.e.: > > > > with SomeObject o1, SomeOtherObject o2 do > > That's perfectly fine for C. But this isn't C. > What's wrong here? In pascal, we also s

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-18 Thread Marco van de Voort
In our previous episode, Xiangrong Fang said: > Alternatively, how about just use SPACE to separate the token? i.e.: > > with SomeObject o1, SomeOtherObject o2 do That's perfectly fine for C. But this isn't C. ___ fpc-pascal maillist - fpc-pascal@

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-18 Thread Xiangrong Fang
Alternatively, how about just use SPACE to separate the token? i.e.: with SomeObject o1, SomeOtherObject o2 do Because you need a COMMA for 2 or more expressions in with, and SPACE is not valid in token? 2013/3/18 Sven Barth > Am 18.03.2013 04:17 schrieb "Xiangrong Fang" : > > > > > OK, I

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-18 Thread Paul Ishenin
18.03.13, 11:16, Xiangrong Fang пишет: OK, I see. However I feel "=>" a very "un-pascal" thing, remind me of PHP. :-) I guess "as" would also complicate the parser? I did not suggest to use '=>' I wrote: > Where '=>' is some token which can't be used in expressions. Which means replace '=>

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-17 Thread Sven Barth
Am 18.03.2013 04:17 schrieb "Xiangrong Fang" : > > OK, I see. However I feel "=>" a very "un-pascal" thing, remind me of PHP. :-) I guess "as" would also complicate the parser? As already written by others: "as" is one of the worst tokens you can choose for this, as it is perfectly legal to do

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-17 Thread Xiangrong Fang
OK, I see. However I feel "=>" a very "un-pascal" thing, remind me of PHP. :-) I guess "as" would also complicate the parser? 2013/3/18 Paul Ishenin > 18.03.13, 9:27, Xiangrong Fang пишет: > > I am sorry I didn't follow this thread although I am the "OP" :-). If >> I understand correct, I w

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-17 Thread Paul Ishenin
18.03.13, 9:27, Xiangrong Fang пишет: I am sorry I didn't follow this thread although I am the "OP" :-). If I understand correct, I would suggest NOT introduce the "absolute" keyword, instead, make it ALWAYS absolute. i.e.: with a = SomeObject, b = SomeRecord do begin ... ... end; Both a a

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-17 Thread Xiangrong Fang
I am sorry I didn't follow this thread although I am the "OP" :-). If I understand correct, I would suggest NOT introduce the "absolute" keyword, instead, make it ALWAYS absolute. i.e.: with a = SomeObject, b = SomeRecord do begin ... ... end; Both a and b are "reference" to the object or rec

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-17 Thread Flávio Etrusco
On Sun, Mar 17, 2013 at 2:10 PM, Sven Barth wrote: > On 17.03.2013 15:33, Flávio Etrusco wrote: >> >> (...) >> static int IndexOf(List p_list, T p_item); > > > So you're basically just talking about generic methods here? Yes. Or actually not, it also involves allowing non-specialized/not-complet

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-17 Thread Sven Barth
On 17.03.2013 15:29, Jonas Maebe wrote: On 17 Mar 2013, at 15:02, Luca Olivetti wrote: Al 17/03/13 13:54, En/na Marco van de Voort ha escrit: In our previous episode, Sven Barth said: Texas Instruments' Pascal had an extension of the with statement, IIRC it used = instead of AS With a=Very

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-17 Thread Sven Barth
On 17.03.2013 15:07, Paul Ishenin wrote: If I need to choose from 3, 4 and 5 I would use ':=' syntax because it more like to assignment: with a := TStringList.Create do begin Text := 'bla'; DoSomething(a); Free; end; Yes, I would prefer the ":=" as well because it's basically an assi

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-17 Thread Sven Barth
On 17.03.2013 15:33, Flávio Etrusco wrote: On Sun, Mar 17, 2013 at 6:59 AM, Sven Barth wrote: On 17.03.2013 06:00, Flávio Etrusco wrote: type generic TAlias1 = class(TObject) function Alias1: T; end; This already works. In 2.7 I assume, because it doesn't work in 2.6.2. Grea

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-17 Thread Mark Morgan Lloyd
Marco van de Voort wrote: In our previous episode, Sven Barth said: Texas Instruments' Pascal had an extension of the with statement, IIRC it used = instead of AS With a=VeryLongNameForARecord, b=AnotherRecordWithAVeryLongName do ... Now THAT is really unpascalish... either ":=" or the already

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-17 Thread Flávio Etrusco
On Sun, Mar 17, 2013 at 6:59 AM, Sven Barth wrote: > On 17.03.2013 06:00, Flávio Etrusco wrote: >> >>type generic TAlias1 = class(TObject) >> function Alias1: T; >>end; > > This already works. In 2.7 I assume, because it doesn't work in 2.6.2. Great anyway :) >> function Alias1(So

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-17 Thread Jonas Maebe
On 17 Mar 2013, at 15:02, Luca Olivetti wrote: > Al 17/03/13 13:54, En/na Marco van de Voort ha escrit: >> In our previous episode, Sven Barth said: Texas Instruments' Pascal had an extension of the with statement, IIRC it used = instead of AS With a=VeryLongNameForARec

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-17 Thread Flávio Etrusco
> On 17/03/2013 12:54, Marco van de Voort wrote: >> >> Since it is a pseudo variable declaration, I would assume VAR syntax and >> just use ":" ? This is indeed better. On Sun, Mar 17, 2013 at 10:51 AM, Martin wrote: > Or maybe it should require a "variable" declaration (or otherwise declared >

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-17 Thread Paul Ishenin
17.03.13, 20:16, Sven Barth пишет: But we aren't in a constant or type section here. Also one uses ":=" in the for-loop header. I agree that ':=' should be used but I would not say that '=' is not pascalish :) Let's look look at possibilities: 1. 'as' can't be used because we can use expre

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-17 Thread Luca Olivetti
Al 17/03/13 13:54, En/na Marco van de Voort ha escrit: > In our previous episode, Sven Barth said: >>> >>> Texas Instruments' Pascal had an extension of the with statement, IIRC >>> it used = instead of AS >>> >>> With a=VeryLongNameForARecord, b=AnotherRecordWithAVeryLongName do ... >> >> Now THAT

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-17 Thread Luca Olivetti
Al 17/03/13 13:16, En/na Sven Barth ha escrit: > On 17.03.2013 11:42, Paul Ishenin wrote: >> 17.03.13, 18:25, Sven Barth пишет: With a=VeryLongNameForARecord, b=AnotherRecordWithAVeryLongName do ... >>> >>> Now THAT is really unpascalish... either ":=" or the already suggested >>> "as"... >> >

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-17 Thread Martin
On 17/03/2013 12:54, Marco van de Voort wrote: In our previous episode, Sven Barth said: Now THAT is really unpascalish... either ":=" or the already suggested "as"... Since it is a pseudo variable declaration, I would assume VAR syntax and just use ":" ? Or maybe it should require a "variab

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-17 Thread Marco van de Voort
In our previous episode, Sven Barth said: > > > > Texas Instruments' Pascal had an extension of the with statement, IIRC > > it used = instead of AS > > > > With a=VeryLongNameForARecord, b=AnotherRecordWithAVeryLongName do ... > > Now THAT is really unpascalish... either ":=" or the already sugge

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-17 Thread Marco van de Voort
In our previous episode, Sven Barth said: > > I think having functions/procedures with no arguments callable with > > procedurename() is un-pascal-like as well, but it hardly bothers me that > > FPK allows it. Just because I don't love it doesn't mean others don't. > > (There is a lot of C lik

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-17 Thread Sven Barth
On 17.03.2013 11:42, Paul Ishenin wrote: 17.03.13, 18:25, Sven Barth пишет: With a=VeryLongNameForARecord, b=AnotherRecordWithAVeryLongName do ... Now THAT is really unpascalish... either ":=" or the already suggested "as"... Why? Constants and Types are also use '=' instead of ':=' for assi

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-17 Thread Sven Barth
On 17.03.2013 11:53, Mattias Gaertner wrote: On Sun, 17 Mar 2013 11:25:05 +0100 Sven Barth wrote: [...] Now THAT is really unpascalish... either ":=" or the already suggested "as"... The AS syntax bites already existing syntax. Right. Then better ":=". Regards, Sven _

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-17 Thread Mattias Gaertner
On Sun, 17 Mar 2013 19:05:05 +0800 Xiangrong Fang wrote: > > The AS syntax bites already existing syntax. > > May I know what's the existing syntax? with A as T do Mattias ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freep

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-17 Thread Xiangrong Fang
> The AS syntax bites already existing syntax. May I know what's the existing syntax? ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-17 Thread Mattias Gaertner
On Sun, 17 Mar 2013 11:25:05 +0100 Sven Barth wrote: >[...] > Now THAT is really unpascalish... either ":=" or the already suggested > "as"... The AS syntax bites already existing syntax. Mattias ___ fpc-pascal maillist - fpc-pascal@lists.freepasca

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-17 Thread Paul Ishenin
17.03.13, 18:25, Sven Barth пишет: With a=VeryLongNameForARecord, b=AnotherRecordWithAVeryLongName do ... Now THAT is really unpascalish... either ":=" or the already suggested "as"... Why? Constants and Types are also use '=' instead of ':=' for assignments. Best regards, Paul Ishenin _

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-17 Thread Sven Barth
On 17.03.2013 11:07, Luca Olivetti wrote: Al 17/03/13 03:37, En/na Flávio Etrusco ha escrit: unfortunate, because IMO the 'with' syntax is one of the most abominable un-pascal things Borland introduced in the language, and *forcing* the AS syntax (but probably with some other keyword like ALIAS

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-17 Thread Luca Olivetti
Al 17/03/13 03:37, En/na Flávio Etrusco ha escrit: > unfortunate, because IMO the 'with' syntax is one of the most > abominable un-pascal things Borland introduced in the language, and > *forcing* the AS syntax (but probably with some other keyword like > ALIAS) would make it much more palatable.

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-17 Thread Sven Barth
On 17.03.2013 06:00, Flávio Etrusco wrote: On Sun, Mar 17, 2013 at 12:16 AM, Daniel Gaspary wrote: On Sun, Mar 17, 2013 at 12:07 AM, 印場 乃亜 wrote: On 2013/03/17, at 11:37, Flávio Etrusco wrote: Daniel, I find this hack as ingenious as atrocious ;-) But thinking about it a bit, when FPC gets

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-17 Thread Sven Barth
On 17.03.2013 04:07, 印場 乃亜 wrote: I think having functions/procedures with no arguments callable with procedurename() is un-pascal-like as well, but it hardly bothers me that FPK allows it. Just because I don't love it doesn't mean others don't. (There is a lot of C like syntax that has cree

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-16 Thread Flávio Etrusco
On Sun, Mar 17, 2013 at 12:16 AM, Daniel Gaspary wrote: > On Sun, Mar 17, 2013 at 12:07 AM, 印場 乃亜 wrote: >> On 2013/03/17, at 11:37, Flávio Etrusco wrote: >>> Daniel, I find this hack as ingenious as atrocious ;-) >>> But thinking about it a bit, when FPC gets generic methods you can >>> make th

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-16 Thread Daniel Gaspary
On Sun, Mar 17, 2013 at 12:07 AM, 印場 乃亜 wrote: > On 2013/03/17, at 11:37, Flávio Etrusco wrote: >> Daniel, I find this hack as ingenious as atrocious ;-) >> But thinking about it a bit, when FPC gets generic methods you can >> make this kind of workable! I was thinking about this, not specifical

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-16 Thread Flávio Etrusco
> Actually the only thing that makes me uncomfortable about the keyword "as", > is that > it strangely reminds me of SQL. I suppose that isn't a bad thing though. No problem with SQL, but "as" is already safe typecast, remember? ;-) -Flávio ___ fpc-pa

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-16 Thread 印場 乃亜
Hi, On 2013/03/17, at 11:37, Flávio Etrusco wrote: > > No, he's saying that *his hack* using class helper wouldn't cover this > case (two objects in the same 'with' clause). > Well, more to the point, it only works with OOP. I use WITH on structures, etc. all the time, so ... yes implementing

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-16 Thread 印場 乃亜
Hi, Also with using the "longobj" below, you have to declare it first (yet more manual temporary/helper variables). Also, once you do that, you don't need with as much to begin with since you could use a single char. variable name. BTW, I don't think Daniel was suggesting that we actually use

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-16 Thread Flávio Etrusco
On Sat, Mar 16, 2013 at 10:14 PM, Xiangrong Fang wrote: >> > I don't know what's make it complex if there are 2 or more subject in >> > the with? >> >> Context. A conflict case the two object were of the same class. > > > Are you saying this case: > > with MyClassInstance1 as m, MyClassInstance2

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-16 Thread Xiangrong Fang
> > > I don't know what's make it complex if there are 2 or more subject in > the with? > > Context. A conflict case the two object were of the same class. > Are you saying this case: with MyClassInstance1 as m, MyClassInstance2 do begin m.Property1 := 123; Property2 := 456; end; Here you d

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-16 Thread Daniel Gaspary
On Sat, Mar 16, 2013 at 7:55 PM, Xiangrong Fang wrote: > I don't think a class helper is worth for this stuff, if I need to write a > helper I would rather do this: I am not sure that I understand your point. The Class helper was a way to show how it's possible. And with that helper, ALL objects

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-16 Thread Xiangrong Fang
shiruba 's example is better than mine, and was exactly the reason I posted this suggestion. I don't think a class helper is worth for this stuff, if I need to write a helper I would rather do this: longobj := BigLongThingIDontWantToWriteOutEverySingleTime; With longobj do begin Height := 100;

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-16 Thread Daniel Gaspary
On Sat, Mar 16, 2013 at 3:02 PM, 印場 乃亜 wrote: > With BigLongThingIDontWantToWriteOutEverySingleTime do > begin > Height := 100; > Width := 200; > ... > SomeOtherObject.Submit(BigLongThingIDontWantToWriteOutEverySingleTime); > end; > > Notice how I have to write the long thin

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-16 Thread 印場 乃亜
Hi, I also think this would be useful, but for other reasons, often times I end up with code like the following: With BigLongThingIDontWantToWriteOutEverySingleTime do begin Height := 100; Width := 200; ... SomeOtherObject.Submit(BigLongThingIDontWantToWriteOutEverySingleTim

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-16 Thread Xiangrong Fang
; 发送自魅族MX > > 原始邮件 > 发件人:Sven Barth > 时间:3月16日 17:12 周六 > 收件人:FPC-Pascal users discussions > 主题:Re: [fpc-pascal] a proposal about "with" syntax > > > Am 16.03.2013 07:14 schrieb "Xiangrong Fang" : > > > >

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-16 Thread Xiangrong Fang
In my example, you can use Items[], but in my real project it is a record with 发送自魅族MX 原始邮件 发件人:Sven Barth 时间:3月16日 17:12 周六 收件人:FPC-Pascal users discussions 主题:Re: [fpc-pascal] a proposal about "with" syntax >Am 16.03.2013 07:14 schrieb "Xiangrong Fang&

Re: [fpc-pascal] a proposal about "with" syntax

2013-03-16 Thread Sven Barth
Am 16.03.2013 07:14 schrieb "Xiangrong Fang" : > > Suppose I have the following class: > > type > TMyClass = class > public > property Caption: string read FCaption write FCaption; > property Items[Index: Integer]: string read GetItem write SetItem; default; > function Count: Intege

[fpc-pascal] a proposal about "with" syntax

2013-03-15 Thread Xiangrong Fang
Suppose I have the following class: type TMyClass = class public property Caption: string read FCaption write FCaption; property Items[Index: Integer]: string read GetItem write SetItem; default; function Count: Integer; end; I would like to do this: with MyClassInstance as mci