Do you also find PowerLanguage somewhat sloppy?  [SOLVED]

Questions about MultiCharts and user contributed studies.
User avatar
JoshM
Posts: 2099
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1526 times
Been thanked: 1503 times
Contact:

Do you also find PowerLanguage somewhat sloppy?

Postby JoshM » 19 Sep 2014

Hi,

Something I dislike about PowerLanguage (compared to other languages) is the sloppiness in naming keywords. I prefer Camel case (LikeThisExample) for keywords and Pascal case for variables (likeThisExample). But it seems that PowerLanguage cannot make up its mind.

"Old" keywords all seem to be in Camel case in the PowerLanguage 'pull down menu' when typing:

Code: Select all

NumToStr
Date
Other keywords don't use capitalisation at all:

Code: Select all

computerdatetime
currentbar
currentdate
netprofit
(To further add to the inconsistency, in the wiki currentbar is named CurrentBar and currentdate CurrentDate).

Recent keywords even use underscores very heavily, perhaps because keywords in all lower case do not help quick reading?

Code: Select all

pmms_strategy_allow_long_entries
pmms_get_strategy_named_num
pmm_set_my_named_num
This is not a huge problem, because the code compiles if one uses 'currentbar', 'curRENTBAR', or 'CurrentBar'. But I personally see the following drawbacks:

* Inconsistent naming looks sloppy,
* It makes PowerLanguage look more like a 'scripting' language than a programming language,
* Keywords in all lower case are harder to quickly scan.

What are your thoughts on this?

User avatar
TJ
Posts: 7232
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 991 times
Been thanked: 2058 times

Re: Do you also find PowerLanguage somewhat sloppy?

Postby TJ » 19 Sep 2014

What is the "q" in Q_Time_DT ?

User avatar
TJ
Posts: 7232
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 991 times
Been thanked: 2058 times

Re: Do you also find PowerLanguage somewhat sloppy?

Postby TJ » 19 Sep 2014

From wiki:

Image
Attachments
Type inconsistency.jpg
(8.96 KiB) Downloaded 1892 times

User avatar
ABC
Posts: 636
Joined: 16 Dec 2006
Has thanked: 120 times
Been thanked: 359 times
Contact:

Re: Do you also find PowerLanguage somewhat sloppy?

Postby ABC » 19 Sep 2014

JoshM,

I agree to what you wrote and must say I prefer camel case, too. In my opinion the inconsistencies are simply caused as over the course of the lifetime of Easylanguage different developers have been responsible for the implementation and there was/is no best practice, or set of rules for that. And of course because it all originates from Pascal and letter cases are ignored there so you are not forced to be accurate.

TJ, I'd guess that "Q" indicates that this is information from a quote field.

Regards,
ABC

User avatar
JoshM
Posts: 2099
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1526 times
Been thanked: 1503 times
Contact:

Re: Do you also find PowerLanguage somewhat sloppy?

Postby JoshM » 05 Oct 2014

There are also syntax inconsistencies in PowerLanguage, and that is perhaps more important than capitalisation differences.

For example, we can use parentheses with while loops:

Code: Select all

while (x < 30) begin

Print("The value of 'x' is: ", x);

x = x + 1;

end;
But using parentheses in for loops gives the "numerical variable expected" error:

Code: Select all

for (x = 0 to 30) begin

Print("The value of 'x' is: ", x);

end;

Code: Select all

for (x = 0) to 30 begin

Print("The value of 'x' is: ", x);

end;

User avatar
JoshM
Posts: 2099
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1526 times
Been thanked: 1503 times
Contact:

Re: Do you also find PowerLanguage somewhat sloppy?

Postby JoshM » 14 Oct 2014

There are three inconsistencies with the repeat-until loop:

1) It does not allow the use of `begin` and `end`. That is odd, because:
-- The use of `begin` and `end` is mandatory for all other loops, and
-- `begin` and `end` mark a code block and these are commonly used in other programming languages when looping.

Code: Select all

x = 0;

repeat begin
Print("x = ", x);
x = x + 1;
end until x = 5;

Code: Select all

syntax error, unexpected 'until', expecting ';'
Suggestion:
Make the repeat-while loop accept the `begin` and `end` keywords optionally (!) so that this loop works consistently with the other loops.


-----------------


2) Using the parentheses (like we can do with the `while` loop) only causes the loop to run once, but the PowerLanguage Editor does not give an error when using parentheses.

Code: Select all

x = 0;

repeat
Print("x = ", x);
x = x + 1;
until (x = 5);

Code: Select all

x = 0.00
Without parentheses:

Code: Select all

x = 0;

repeat
Print("x = ", x);
x = x + 1;
until x = 5;

Code: Select all

x = 0.00
x = 1.00
x = 2.00
x = 3.00
x = 4.00
Suggestion:
If the repeat-while loop cannot work with parentheses, the editor should give an error to highlight this to the user. In the current situation, one can spend a lot of time debugging this situation because no error is triggered.


--------------


3) Oddly enough, in some situations parentheses are required to make the repeat-until loop run correctly.

This loop only runs once:

Code: Select all

x = 0;

repeat
Print("x = ", x);
x = x + 1;
until x < 5;

Code: Select all

x = 0.00
But if we add parentheses, it runs correctly:

Code: Select all

x = 0;

repeat
Print("x = ", x);
x = x + 1;
until (x < 5);

Code: Select all

x = 0.00
x = 1.00
x = 2.00
x = 3.00
x = 4.00
This is so inconsistent that I don't understand it. Is the rule of the undocumented repeat-until loop the following?

* "When the `until` condition uses the equal sign, parentheses should not be used because then the loop only runs once. But if you use a less than sign in the `until` condition, you should use parentheses because without them the loop only runs once."

To further add to the confusion, the wiki example for the GetAppInfo keyword uses parentheses with the repeat-until loop, but the FAQ does not.

-> MultiCharts Support, please address this last situation.

(Using MultiCharts64 Version 9.0 Release (Build 10014))

User avatar
JoshM
Posts: 2099
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1526 times
Been thanked: 1503 times
Contact:

Re: Do you also find PowerLanguage somewhat sloppy?  [SOLVED]

Postby JoshM » 25 Oct 2014

I find it slightly disappointing that there is, after 36 days, no response from MultiCharts Support on this topic, not even the common text that 'all ideas are forwarded and evaluated in a timely manner'.

I thought a feedback topic on PowerLanguage would be valuable, where we could combine the viewpoints from different users to generate ideas that make PowerLanguage even better.

But instead the lack of dialogue suggests to me that I misunderstood the purpose of the forum topics. It feels a little bit odd that spending free time on answering users' questions is welcomed (i.e., partly doing what otherwise would need to be done by MultiCharts Support), but that posting ideas and suggestions is 'frowned upon' (don't know how I should otherwise interpret the ignoring of this topic).

Well, learning this at least saves me a lot of time that would otherwise would have been spend on the forum. :)

User avatar
ABC
Posts: 636
Joined: 16 Dec 2006
Has thanked: 120 times
Been thanked: 359 times
Contact:

Re: Do you also find PowerLanguage somewhat sloppy?

Postby ABC » 25 Oct 2014

I am glad that I am not alone with this feeling, but it's sad and I'd love have it otherwise. I guess I just have to live with and adapt to it.

Regards,
ABC
I find it slightly disappointing that there is, after 36 days, no response from MultiCharts Support on this topic, not even the common text that 'all ideas are forwarded and evaluated in a timely manner'.

I thought a feedback topic on PowerLanguage would be valuable, where we could combine the viewpoints from different users to generate ideas that make PowerLanguage even better.

But instead the lack of dialogue suggests to me that I misunderstood the purpose of the forum topics. It feels a little bit odd that spending free time on answering users' questions is welcomed (i.e., partly doing what otherwise would need to be done by MultiCharts Support), but that posting ideas and suggestions is 'frowned upon' (don't know how I should otherwise interpret the ignoring of this topic).

Well, learning this at least saves me a lot of time that would otherwise would have been spend on the forum. :)

User avatar
Henry MultiСharts
Posts: 9132
Joined: 25 Aug 2011
Has thanked: 1260 times
Been thanked: 2929 times

Re: Do you also find PowerLanguage somewhat sloppy?

Postby Henry MultiСharts » 27 Oct 2014

There are also syntax inconsistencies in PowerLanguage, and that is perhaps more important than capitalisation differences. For example, we can use parentheses with while loops:

Code: Select all

while (x < 30) begin
Print("The value of 'x' is: ", x);
x = x + 1;
end;
But using parentheses in for loops gives the "numerical variable expected" error:

Code: Select all

for (x = 0 to 30) begin
Print("The value of 'x' is: ", x);
end;

Code: Select all

for (x = 0) to 30 begin
Print("The value of 'x' is: ", x);
end;
This was done for backward compatibility with TS EL. Please do not use the parentheses with the FOR loop.
There are three inconsistencies with the repeat-until loop:
1) It does not allow the use of `begin` and `end`. That is odd, because:
-- The use of `begin` and `end` is mandatory for all other loops, and
-- `begin` and `end` mark a code block and these are commonly used in other programming languages when looping.

Code: Select all

x = 0;repeat begin
Print("x = ", x);
x = x + 1;
end until x = 5;

Code: Select all

syntax error, unexpected 'until', expecting ';'
Suggestion:
Make the repeat-while loop accept the `begin` and `end` keywords optionally (!) so that this loop works consistently with the other loops.
This was also done for backward compatibility with TS EL. You need to place a semicolon between end; until and it will work ok.

Code: Select all

repeat begin
Print("x = ", x);
x = x + 1;
end; until x = 5;

User avatar
Henry MultiСharts
Posts: 9132
Joined: 25 Aug 2011
Has thanked: 1260 times
Been thanked: 2929 times

Re: Do you also find PowerLanguage somewhat sloppy?

Postby Henry MultiСharts » 27 Oct 2014

2) Using the parentheses (like we can do with the `while` loop) only causes the loop to run once, but the PowerLanguage Editor does not give an error when using parentheses.

Code: Select all

x = 0;
repeat
Print("x = ", x);
x = x + 1;
until (x = 5);

Code: Select all

x = 0.00
Without parentheses:

Code: Select all

x = 0;
repeat
Print("x = ", x);
x = x + 1;
until x = 5;

Code: Select all

x = 0.00
x = 1.00
x = 2.00
x = 3.00
x = 4.00
Suggestion:
If the repeat-while loop cannot work with parentheses, the editor should give an error to highlight this to the user. In the current situation, one can spend a lot of time debugging this situation because no error is triggered.
That is a known issue that will be resolved in MultiCharts 9.0 Release 2.
3) Oddly enough, in some situations parentheses are required to make the repeat-until loop run correctly. This loop only runs once:

Code: Select all

x = 0;
repeat
Print("x = ", x);
x = x + 1;
until x < 5;

Code: Select all

x = 0.00
But if we add parentheses, it runs correctly:

Code: Select all

x = 0;

repeat
Print("x = ", x);
x = x + 1;
until (x < 5);

Code: Select all

x = 0.00
x = 1.00
x = 2.00
x = 3.00
x = 4.00
This is so inconsistent that I don't understand it. Is the rule of the undocumented repeat-until loop the following?

* "When the `until` condition uses the equal sign, parentheses should not be used because then the loop only runs once. But if you use a less than sign in the `until` condition, you should use parentheses because without them the loop only runs once."

To further add to the confusion, the wiki example for the GetAppInfo keyword uses parentheses with the repeat-until loop, but the FAQ does not.

-> MultiCharts Support, please address this last situation.

(Using MultiCharts64 Version 9.0 Release (Build 10014))
That is not related to the Equal/Less Than sign. Repeat Until evaluates the statements in a loop and exits the loop only when the Until condition is true. In your case the condition has been met on the first calculation, that is why the loop was exited at once.

hilbert
Posts: 224
Joined: 17 Aug 2011
Has thanked: 76 times
Been thanked: 64 times

Re: Do you also find PowerLanguage somewhat sloppy?

Postby hilbert » 28 Oct 2014

one small request:
In long codes with multiple begin-end constructs, its irritating and sometimes it becomes difficult to type correct number of "end" to match with number of "begin". This results in error on compiling and again we have to go and carefully match each "begin" with a corresponding "end".

A nice little functionality would be as soon as I type "begin " in powerlanguage editor, "end" should appear automatically.
Thanks a lot!

User avatar
Henry MultiСharts
Posts: 9132
Joined: 25 Aug 2011
Has thanked: 1260 times
Been thanked: 2929 times

Re: Do you also find PowerLanguage somewhat sloppy?

Postby Henry MultiСharts » 29 Oct 2014

one small request:
In long codes with multiple begin-end constructs, its irritating and sometimes it becomes difficult to type correct number of "end" to match with number of "begin". This results in error on compiling and again we have to go and carefully match each "begin" with a corresponding "end".

A nice little functionality would be as soon as I type "begin " in powerlanguage editor, "end" should appear automatically.
Thanks a lot!
hilbert, thank you for your suggestion. You may want to submit a feature request to the Project Management of our web site so other users can vote for it: https://www.multicharts.com/pm/

hilbert
Posts: 224
Joined: 17 Aug 2011
Has thanked: 76 times
Been thanked: 64 times

Re: Do you also find PowerLanguage somewhat sloppy?

Postby hilbert » 29 Oct 2014

one small request:
In long codes with multiple begin-end constructs, its irritating and sometimes it becomes difficult to type correct number of "end" to match with number of "begin". This results in error on compiling and again we have to go and carefully match each "begin" with a corresponding "end".

A nice little functionality would be as soon as I type "begin " in powerlanguage editor, "end" should appear automatically.
Thanks a lot!
hilbert, thank you for your suggestion. You may want to submit a feature request to the Project Management of our web site so other users can vote for it: https://www.multicharts.com/pm/
Done. Here is the PM entry:

https://www.multicharts.com/pm/viewissu ... no=MC-1786

orion
Posts: 250
Joined: 01 Oct 2014
Has thanked: 65 times
Been thanked: 104 times

Re: Do you also find PowerLanguage somewhat sloppy?

Postby orion » 30 Oct 2014

There are also syntax inconsistencies in PowerLanguage, and that is perhaps more important than capitalisation differences. For example, we can use parentheses with while loops:

Code: Select all

while (x < 30) begin
Print("The value of 'x' is: ", x);
x = x + 1;
end;
But using parentheses in for loops gives the "numerical variable expected" error:

Code: Select all

for (x = 0 to 30) begin
Print("The value of 'x' is: ", x);
end;

Code: Select all

for (x = 0) to 30 begin
Print("The value of 'x' is: ", x);
end;
This was done for backward compatibility with TS EL. Please do not use the parentheses with the FOR loop.
There are three inconsistencies with the repeat-until loop:
1) It does not allow the use of `begin` and `end`. That is odd, because:
-- The use of `begin` and `end` is mandatory for all other loops, and
-- `begin` and `end` mark a code block and these are commonly used in other programming languages when looping.

Code: Select all

x = 0;repeat begin
Print("x = ", x);
x = x + 1;
end until x = 5;

Code: Select all

syntax error, unexpected 'until', expecting ';'
Suggestion:
Make the repeat-while loop accept the `begin` and `end` keywords optionally (!) so that this loop works consistently with the other loops.
This was also done for backward compatibility with TS EL. You need to place a semicolon between end; until and it will work ok.

Code: Select all

repeat begin
Print("x = ", x);
x = x + 1;
end; until x = 5;
With just two weeks into MC, I am a new PL user but I am finding that to their credit the PL designers have made good effort to make PL compatible with EL and all its warts included. On the topic of the repeat/until loop, either use a semicolon as mentioned by Henry or don't have the begin/end at all as per this excerpt from the EL guide: "There is no need to use the begin/end keywords to group more than one program statement in a repeat/until loop as all statements between repeat and until are treated as a block."

orion
Posts: 250
Joined: 01 Oct 2014
Has thanked: 65 times
Been thanked: 104 times

Re: Do you also find PowerLanguage somewhat sloppy?

Postby orion » 30 Oct 2014

There are also syntax inconsistencies in PowerLanguage, ...
... On the topic of the repeat/until loop, either use a semicolon as mentioned by Henry or don't have the begin/end at all as per this excerpt from the EL guide: "There is no need to use the begin/end keywords to group more than one program statement in a repeat/until loop as all statements between repeat and until are treated as a block."
I should also mention that while PL has done an admirable job of ensuring EL compatibility, the repeat/until code posted on this forum points to some PL bug since I get two different results with and without the parentheses for the until condition but parentheses or lack thereof make no difference when tested in TS EL. The code is posted below.

Code: Select all

vars: x (0);
once begin
x = 0;
repeat
print("x = ", x);
x = x + 1;
until (x < 5);
end;

User avatar
Henry MultiСharts
Posts: 9132
Joined: 25 Aug 2011
Has thanked: 1260 times
Been thanked: 2929 times

Re: Do you also find PowerLanguage somewhat sloppy?

Postby Henry MultiСharts » 31 Oct 2014

I should also mention that while PL has done an admirable job of ensuring EL compatibility, the repeat/until code posted on this forum points to some PL bug since I get two different results with and without the parentheses for the until condition but parentheses or lack thereof make no difference when tested in TS EL. The code is posted below.

Code: Select all

vars: x (0);
once begin
x = 0;
repeat
print("x = ", x);
x = x + 1;
until (x < 5);
end;
orion, as I have specified in post #10 - that is a known issue that will be resolved in MultiCharts 9.0 Release 2.


Return to “MultiCharts”