Recent

Author Topic: Adding integers?  (Read 10058 times)

A

  • Guest
Re: Adding integers?
« Reply #15 on: December 26, 2017, 09:14:59 pm »
It is a feature I requested myself
I'm probably misunderstanding, but does that mean that the community is able to influence the features of the dialect of ObjPas that Lazarus uses? If that's what you mean, then that's awesome.

Thaddy

  • Hero Member
  • *****
  • Posts: 18524
  • Here stood a man who saw the Elbe and jumped it.
Re: Adding integers?
« Reply #16 on: December 26, 2017, 09:23:49 pm »
It is a feature I requested myself
I'm probably misunderstanding, but does that mean that the community is able to influence the features of the dialect of ObjPas that Lazarus uses? If that's what you mean, then that's awesome.
Yes!! If it has some merit and one of the compiler devs picks it up you may see a request implemented. This happens quite often.
In this case it was a matter of Delphi compatibility, though. Which sometimes has a somewhat higher priority.
And there is never a guarantee.
E.g.: {$mode fpc} and {$mode objfpc} are modes that contain features that are only in FreePascal and dreamed up by users and compiler devs.
Code: Pascal  [Select][+][-]
  1. x+=y;// meaning x := x+y,in mode objfpc
The other modes are compatibility modes to other Pascal dialects.
« Last Edit: December 26, 2017, 09:40:15 pm by Thaddy »
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

Thaddy

  • Hero Member
  • *****
  • Posts: 18524
  • Here stood a man who saw the Elbe and jumped it.
Re: Adding integers?
« Reply #17 on: December 26, 2017, 09:49:50 pm »
Actually in Pascal it is not quite boxing, but it is related to boxing. Here typehelpers are used. in Jaxx it is an object and in xxxphi it is also a typehelper.
See https://en.wikipedia.org/wiki/Object_type_(object-oriented_programming)#Boxing

[edit: answering in plain air, something disappeared... O:-)] But I like Ja and Phi too.... Don't do that! Confuses discussion.
Can you plz put it back? It wasn't offensive and gave me the chance to mention theory and a pointer to it. TNX! <slightly grumpy  >:D 8-)>
« Last Edit: December 26, 2017, 09:58:14 pm by Thaddy »
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

A

  • Guest
Re: Adding integers?
« Reply #18 on: December 26, 2017, 10:39:36 pm »
It is a feature I requested myself
I'm probably misunderstanding, but does that mean that the community is able to influence the features of the dialect of ObjPas that Lazarus uses? If that's what you mean, then that's awesome.
Yes!! If it has some merit and one of the compiler devs picks it up you may see a request implemented. This happens quite often.
In this case it was a matter of Delphi compatibility, though. Which sometimes has a somewhat higher priority.
And there is never a guarantee.
E.g.: {$mode fpc} and {$mode objfpc} are modes that contain features that are only in FreePascal and dreamed up by users and compiler devs.
Code: Pascal  [Select][+][-]
  1. x+=y;// meaning x := x+y,in mode objfpc
The other modes are compatibility modes to other Pascal dialects.
That's great, however I'm a bit confused by your last post :P

Who's Ja and Phi? What disappeared? What do you want me to put back? Lol  :-[

Thaddy

  • Hero Member
  • *****
  • Posts: 18524
  • Here stood a man who saw the Elbe and jumped it.
Re: Adding integers?
« Reply #19 on: December 26, 2017, 11:23:16 pm »
Well, some naughty boy deleted his post while I was answering.
It read something like this:
Quote
  integer.AsString; like japhi, yes?
This is not the exact post but very, very close....
It was in between your post and mine, moderators will confirm this, but he deleted this naughty remark...hence it became confusing to you and me... :o ;D >:( :D

It refers to language features that come from Java or Delphi or C# that some old ignorant hands do not like.. O:-) Like boxing, or in our case type helpers for simple types.
This behavior can be exlplained as: In Indonesian it is called "Tempo Dulu" The times in the past are gone... In Dutch "vroeger was alles beter" ...In British English "The good times" or "The olden days", etc.

But my revenge is that I edited the Wikipedia entry on boxing (computer science and added the object pascal  entry.... I am naughty too...
https://en.wikipedia.org/wiki/Object_type_(object-oriented_programming)#Type_helpers
[edit] The original re-appeared  O:-) http://forum.lazarus.freepascal.org/index.php/topic,39410.msg270383.html#msg270383
« Last Edit: December 27, 2017, 11:23:09 am by Thaddy »
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: Adding integers?
« Reply #20 on: December 27, 2017, 12:35:12 am »
Well, some naughty boy deleted his post

I still have it on my screen:
Code: Pascal  [Select][+][-]
  1. Number.ToString
is Japlhi way to do conversion.  :D

Thaddy

  • Hero Member
  • *****
  • Posts: 18524
  • Here stood a man who saw the Elbe and jumped it.
Re: Adding integers?
« Reply #21 on: December 27, 2017, 12:41:01 am »
It reappeared...
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

andresayang

  • Full Member
  • ***
  • Posts: 124
Re: Adding integers?
« Reply #22 on: December 27, 2017, 07:10:05 am »
Code: Pascal  [Select][+][-]
  1. Number.ToString

Well well, so simple ... I was still using "string conversion routines" (IntToStr ....)

Thanks for the tip
Linux, Debian 12
Lazarus: always latest release

jamie

  • Hero Member
  • *****
  • Posts: 7405
Re: Adding integers?
« Reply #23 on: December 27, 2017, 05:13:45 pm »
I think the helpers were the best thing since sliced bread!  ;)

 I implemented one for the "Currency" Type for my special needs to make things
easier to handle in code land.

 Also I've notice they handle Inline directives very well in saving code space and making
things speed up a little. This goes along with Record methods too.



The only true wisdom is knowing you know nothing

Thaddy

  • Hero Member
  • *****
  • Posts: 18524
  • Here stood a man who saw the Elbe and jumped it.
Re: Adding integers?
« Reply #24 on: December 28, 2017, 08:25:39 am »
Note all these things are documented here: https://www.freepascal.org/docs-html/rtl/sysutils/typehelpers.html which describes all available typehelpers in the sysutils unit.
Since I understand many of you haven't noticed these, please go and have a look at what is possible (a lot more than you think!)
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

Handoko

  • Hero Member
  • *****
  • Posts: 5507
  • My goal: build my own game engine using Lazarus
Re: Adding integers?
« Reply #25 on: December 28, 2017, 12:22:51 pm »
Link bookmarked.
Thank you.

bytebites

  • Hero Member
  • *****
  • Posts: 767
Re: Adding integers?
« Reply #26 on: December 28, 2017, 01:49:43 pm »
It reappeared...
That's what nerds do!  8-)

There is typo. I meant it to be Japlhi.  (Java-Delphi)

Stringhelper's index is  zero based:

Code: Pascal  [Select][+][-]
  1. var s:string;
  2. begin
  3.   s:='Hello';
  4.   writeln(pos('ello',s)=s.indexof('ello'));
  5. end;
  6.  

Prints False;

Code: Pascal  [Select][+][-]
  1. TStringHelper.Join(
  2.   const Separator: string;
  3.   const Values: array of Const
  4. ):string;
  5.  
  6. result:=astring.join(sep,array);
  7.  

astring is not used at all. I expected that astring is used as separator (as in Python)


 

TinyPortal © 2005-2018