Recent

Author Topic: Please make your language more freedom  (Read 37051 times)

Thaddy

  • Hero Member
  • *****
  • Posts: 14205
  • Probably until I exterminate Putin.
Re: Please make your language more freedom
« Reply #90 on: June 28, 2018, 10:29:13 pm »
plus the fact there are problems on containers limits
Quote
assuming you dont want to call "pack" each iteration
I just today showed you why that is not the case in another thread.
Cocky programmers should be put to rest. If I have a rooster, I'll eat it, no eggs...
Specialize a type, not a var.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: Please make your language more freedom
« Reply #91 on: June 28, 2018, 11:15:07 pm »
This compiles and never runs the loop:

Code: [Select]
var i: integer;
    n: cardinal;
begin
  n := MaxInt + 2;
  writeln(n);
  for i := 0 to n - 1 do begin
    writeln(i);
  end;
end.

This compiles and runs the loop many many times:

Code: [Select]
var i: cardinal;
    n: cardinal;
begin
  n := 0;
  writeln(n);
  for i := 0 to n - 1 do begin
    writeln(i);
  end;
end.

While one could argue that the compiler should warn in the first case due to the different types the second case definitely needs constant propagation. You can enable that using -Ooconstprop though the calls to Writeln() seem to mess that up (can probably be considered a bug). If you replace those calls with another one then you'll notice the following errors:

For your first example at the line of the for-loop:
Code: [Select]
Warning: range check error while evaluating constants (2147483649 must be between -2147483648 and 2147483647)
For your second example also at the line of the for-loop (though strangely this error disappears if range checks are enabled with -CR  :o ):
Code: [Select]
Warning: range check error while evaluating constants (-1 must be between 0 and 4294967295)
Note: tested with trunk.

And this prints 10000. Apparently all smaller types are converted to sizeint/sizeuint when used

Code: [Select]
var b: byte;
begin
  b := 100;
  writeln(b * b);
end.

This one is in fact documented (the remark before the Boolean types section).

mercurhyo

  • Full Member
  • ***
  • Posts: 242
Re: Please make your language more freedom
« Reply #92 on: June 29, 2018, 12:25:14 pm »
Cocky

well done TINY  bummy! NOW EVERYONE can see where came your frustration from ha ha ha
 :D :D :D :D :D
no  you didn't show anything execpt that you are a smallnut, as people already noticed along my readings on this forum
« Last Edit: June 29, 2018, 12:33:22 pm by mercurhyo »
DEO MERCHVRIO - Linux, Win10pro - Ryzen9XT 24threads + Geforce Rtx 3080SUPRIM
god of financial gain, commerce, eloquence (and thus poetry), messages, communication (including divination), travelers, boundaries, luck, trickery and thieves; he also serves as the guide of souls to the underworld

mercurhyo

  • Full Member
  • ***
  • Posts: 242
Re: Please make your language more freedom
« Reply #93 on: June 30, 2018, 03:58:06 am »
Ok let it be "as it is", no problem to me it works for 35 years.
about generic class<curlymathsyms> I will never use that (I can't see a knife under my neck forcing me to use improvements I do not want, as I mentioned) unless I find a way to patch the compiler, replacing "<>" with "[ ]" that is more pascalish to my taste
Using "[…]" is just as much hell for the parser as "<…>" already is as the former conflicts with the array syntax while the latter conflicts with comparisons. Also considering that the "[…]" syntax in const/var sections means sets (which are unordered) a more correct choice would be "(…)" which is for ordered elements in those sections and the type parameters are ordered.

NOPE I will patch the compiler definitely with '[ ... ]', FPC does not use them exclusively with arrays and sets, but also with 'alias', 'public', and other stuffs
https://www.freepascal.org/docs-html/ref/refsu81.html#x199-22100014.10.12

$mode objfpc ===> generics with [ ]
$mode delphi ===> generics with < >
at the best case if I can patch that way
« Last Edit: June 30, 2018, 04:01:23 am by mercurhyo »
DEO MERCHVRIO - Linux, Win10pro - Ryzen9XT 24threads + Geforce Rtx 3080SUPRIM
god of financial gain, commerce, eloquence (and thus poetry), messages, communication (including divination), travelers, boundaries, luck, trickery and thieves; he also serves as the guide of souls to the underworld

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: Please make your language more freedom
« Reply #94 on: June 30, 2018, 10:46:53 am »
Ok let it be "as it is", no problem to me it works for 35 years.
about generic class<curlymathsyms> I will never use that (I can't see a knife under my neck forcing me to use improvements I do not want, as I mentioned) unless I find a way to patch the compiler, replacing "<>" with "[ ]" that is more pascalish to my taste
Using "[…]" is just as much hell for the parser as "<…>" already is as the former conflicts with the array syntax while the latter conflicts with comparisons. Also considering that the "[…]" syntax in const/var sections means sets (which are unordered) a more correct choice would be "(…)" which is for ordered elements in those sections and the type parameters are ordered.

NOPE I will patch the compiler definitely with '[ ... ]', …

Good luck with that  ::)

munair

  • Hero Member
  • *****
  • Posts: 798
  • compiler developer @SharpBASIC
    • SharpBASIC
Re: Please make your language more freedom
« Reply #95 on: July 02, 2018, 12:55:19 am »
As it was mentioned by the OP I played a bit with PascalABC today and it actually looks promising. The IDE still has some flaws. Instantiating forms isn't going as smoothly as it should and some library classes behave unexpectedly, like opening their own window when they shoudn't. But with some work-arounds decent programs can be written. The ability to include .NET components actually make PascalABC quite powerful. The only real problem is that all documentation is in Russian.  :D

Not really the place to put an ad, I know, but as the OP mentioned it, it seemed like the right place to share some findings.
« Last Edit: July 02, 2018, 01:01:46 am by Munair »
keep it simple

giahung1997

  • Full Member
  • ***
  • Posts: 113
Re: Please make your language more freedom
« Reply #96 on: July 02, 2018, 01:46:45 am »

giahung1997

  • Full Member
  • ***
  • Posts: 113
Re: Please make your language more freedom
« Reply #97 on: July 20, 2018, 10:18:20 am »
Your words about cocky programmers made me think again. I'm not even consider myself as a programmer. Perhaps Object Free Pascal is such a big language for me. Luckily I found this when surfing the net: http://www.thinbasic.com Old memory come back, the second language I learned after Pascal is VB6. This thing is small and not features rich like FPC/Lazarus but I think it's enough for me who can only write toy apps. Sadly, it's available for Windows only  :( Thank you for treat me very well when I still active on this forum. Bye and hope we will see each other again  :(

Handoko

  • Hero Member
  • *****
  • Posts: 5131
  • My goal: build my own game engine using Lazarus
Re: Please make your language more freedom
« Reply #98 on: July 20, 2018, 10:56:35 am »
Have you tried these:

Gambas
Although not fully compatible but you can think it is as a VB/VB.net for Linux.
https://en.wikipedia.org/wiki/Gambas

FreeBASIC
It is a multi platform BASIC compiler, it provides syntax compatibility with programs originally written in Microsoft QuickBASIC.
https://en.wikipedia.org/wiki/FreeBASIC

QB64
A self hosting BASIC compiler. It can be used to write simple Android app.
https://en.wikipedia.org/wiki/QB64

They all are free and look interesting.

BeniBela

  • Hero Member
  • *****
  • Posts: 905
    • homepage
Re: Please make your language more freedom
« Reply #99 on: August 17, 2018, 02:38:53 pm »
I just got a new idea.

Rather than the hypothetical scope-restriction

Code: Pascal  [Select][+][-]
  1. begin
  2.   for var i: integer := 1 to 10 do begin
  3.     var j: integer := i + 1;
  4.     //..
  5.   end;
  6.   for var i: integer := 1 to 10 do begin
  7.     var j: integer := i  * i;
  8.     if j mod 2 = 0 then begin
  9.        var k: integer := ///...;
  10.     end;
  11.     //..
  12.   end;
  13. //i, j and k are no longer in scope
  14. end
  15.  

we could use with for every if and for block


Code: Pascal  [Select][+][-]
  1. var for1: record
  2.    i, j: integer;
  3. end;
  4. var for2: record
  5.    i, j: integer;
  6.    if1: record
  7.       k: integer;
  8.    end;
  9. end;
  10. begin
  11.   with for1 do for i := 1 to 10 do begin
  12.     j := i + 1;
  13.     //...
  14.   end;
  15.   with for2 do for i := 1 to 10 do begin
  16.     j := i  * i;
  17.     with if1 do if j mod 2 = 0 then begin
  18.        k := ///...;
  19.     end;
  20.    //...
  21.   end;
  22. //i, j and k are no longer in scope
  23. end
  24.  


Unfortunately fpc cannot use record fields as loop variables. it does not want to put the fields in registers. Why is it treating record fields differently then normal variables? They are all together on the stack

giahung1997

  • Full Member
  • ***
  • Posts: 113
Re: Please make your language more freedom
« Reply #100 on: February 12, 2019, 05:35:01 am »
Have you tried these:

Gambas
Although not fully compatible but you can think it is as a VB/VB.net for Linux.
https://en.wikipedia.org/wiki/Gambas

FreeBASIC
It is a multi platform BASIC compiler, it provides syntax compatibility with programs originally written in Microsoft QuickBASIC.
https://en.wikipedia.org/wiki/FreeBASIC

QB64
A self hosting BASIC compiler. It can be used to write simple Android app.
https://en.wikipedia.org/wiki/QB64

They all are free and look interesting.

Gambas3 is for *nix only and it no longer support Cygwin so it's a no go for Windows user.

Qb64 doesn't have any decent IDE other than it text mode IDE.

FreeBasic looks most promising. It has decent IDE comparable to Lazarus: WinFBE (Windows only) and PoseidonFB (cross platform) and a bunch of smaller projects. But it syntax feared me most. Look at it document page about keywords and operators, there're hundreds and mostly unintuitive.

About ThinBasic I gave up on it just a week after my post above. There was major change with the IDE made it unstable. Perhaps fixed now. I came back to my Fantom camp since then  %)

 

TinyPortal © 2005-2018