Wednesday, February 25, 2015

Digest for comp.lang.c++@googlegroups.com - 9 updates in 3 topics

bleachbot <bleachbot@httrack.com>: Feb 25 10:36PM +0100

bleachbot <bleachbot@httrack.com>: Feb 26 12:05AM +0100

bleachbot <bleachbot@httrack.com>: Feb 26 12:34AM +0100

Ramine <ramine@1.1>: Feb 25 04:37PM -0800

Hello...
 
I have tried to look at the C++ language and compare it to
Object Pascal, because i am also a Delphi and FreePascal develloper
that is using Object Pascal(i mean object pascal that is more powerful,
not pascal), so i have tried to look at the syntax of C++ patiently
to feel more what is C++ and C , and i have come to the follwing conclusion:
 
If you look at the "for" statement:
 
In Object Pascal we write this:
 
for i := 0 to 6 do
 
But in C and C++ we write this:
 
for (i = 0; i < 7; i++)
 
So as you have noticed there is an "i++" that we must add in C and C++,
so Object Pascal is more beautiful and easier here...
 
 
Other than that there is also the "case" statement:
 
In Object Pascal we write this:
 
case n of
0: str := 'alpha';
1: str := 'beta';
2: str := 'gamma';
else
str := 'invalid';
end; // case
 
 
but in C and C++ we write this:
 
switch (n)
{
case 0 : str = "alpha";
break;
case 1 : str = "beta";
break;
case 2 : str = "gamma";
break;
default: str = "invalid";
} // switch
 
 
So notice with me that in C++ and C you have to write
the "switch" word and you have to write all over again many times
the "case" word, but in Object pascal you write only one time
the "case" word, so Object Pascal is beautiful and easier here...
 
 
Other than that i was amazed to not find in C and C++ the data type that
we call "sets" in Object Pascal...
 
For example in Object Pascal we can do this with the "sets" type:
 
type
col_t = (red, blu, grn); // enum.
MySetType := set of col_t;
var
a, b, c : MySetType;
begin
a := []; // empty set
a := a + [red]; // union
b := a - [blu]; // difference
c := a * b; // intersection
if [red] in a then ...
(* Note that sets are generally used to handle non-exclusive flags in
Object Pascal. *)
 
 
But in C and C++ there is no equivalent type of the "sets" of Object
Pascal, so Object Pascal is beautiful and simple easier here again...
 
 
Also in Object Pascal, i have noticed that it's much easier to work with
strings than in C and C++... so Object pascal is more beautiful and
easier here also...
 
 
Also i have noticed that it's much easier to create a dynamic link
library(so or dll) with Delphi or FreePascal than with C++ or C compilers...
 
I think also that i don't need to speak about the macros in C++ or C,
because macros can become easily "cryptic" in C++ or C and that's bad...
 
 
And i have noticed that it's much easier to work with dynamic arrays
with Object Pascal than with C++ or C.
 
So i think i will not continu this comparison between Object Pascal
an C++ and C, because i think C++ and C are a mess.
 
So i think overall Object Pascal is more "beautiful" and easier than C++
and C, and i think that's the strenght of Object Pascal.
 
 
 
 
Thank you,
Amine Moulay Ramdane.
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Feb 25 09:49PM

On 26/02/2015 00:37, Ramine wrote:
 
> for (i = 0; i < 7; i++)
 
> So as you have noticed there is an "i++" that we must add in C and C++,
> so Object Pascal is more beautiful and easier here...
 
ORLY?
 
How would you do this in Object Pascal?
 
for (int i = 1, j = 10; i <= 10; ++i, --j)
 
Is it still beautiful and easier if it is even possible?
 
/Flibble
Ben Bacarisse <ben.usenet@bsb.me.uk>: Feb 25 10:40PM

Ramine <ramine@1.1> writes:
<snip>
 
> for (i = 0; i < 7; i++)
 
> So as you have noticed there is an "i++" that we must add in C and
> C++, so Object Pascal is more beautiful and easier here...
 
What does this loop look like in Object Pascal:
 
for (auto i : { 2, 3, 5, 7, 11, 13, 17 }) f(i);
 
In C++, if you decide you need to generate these numbers and do other
calculation on the collection you can write
 
for (auto i : some_primes) f(i);
 
with some_primes declared in all sort of ways depending on what you need
to do with them:
 
std::set<int> some_primes = { 2, 3, 5, 7, 11, 13, 17 };
std::vector<int> some_primes = { 2, 3, 5, 7, 11, 13, 17 };
std::list<int> some_primes = { 2, 3, 5, 7, 11, 13, 17 };
int some_primes[] = { 2, 3, 5, 7, 11, 13, 17 };
 
without any change to the loop.
 
<snip>
--
Ben.
Ramine <ramine@1.1>: Feb 25 06:05PM -0800

On 2/25/2015 2:40 PM, Ben Bacarisse wrote:
> int some_primes[] = { 2, 3, 5, 7, 11, 13, 17 };
 
> without any change to the loop.
 
> <snip>
 
Hello Ben Becarisse,
 
 
Generics are supports by Object Pascal of Delphi and FreePascal
compilers, and what you are doing above with C++ is creating objects of
classes that supports generics, so you are passing <int>, that means you
are creating objects that has there elements of type "int"...
generics are also supported by Object Pascal of Delphi and FreePascal
compilers, so what you can do with Delphi and FreePascal is create
objects of datastructure that supports generics, in Delphi and
FreePascal we have for example TList datastructure that supports
generics..
 
So we create an Object of TList datastructure using generics as follow
in Object Pascal of the Delphi and FreePascal compilers:
 
var
Item: Integer;
[1] List: TList<Integer>;
 
....
[2] for Item in List do
Writeln(Item);
 
 
 
As in C++, in the Object Pascal code above, notice that in [1] we are
creating and object of class Tlist that supports generics, and in [2],
like in C++, we are using the "for" loop to go through
the elements of the Tlist, this will work with the Object Pascal of the
Delphi and FreePascal compilers.. and you can easily find libraries of
Object Pascal in internet that supports classes that supports generics
and you can do the same as you are doing with C++...so as you have
noticed the Object Pascal of the Delphi and FreePascal are powerful,
they can support generics, and they even support also Lambda expressions
to express more your program in a functional manner ...
 
 
 
Thank you,
Amine Moulay Ramdane.
Ramine <ramine@1.1>: Feb 25 06:34PM -0800

On 2/25/2015 2:40 PM, Ben Bacarisse wrote:
> int some_primes[] = { 2, 3, 5, 7, 11, 13, 17 };
 
> without any change to the loop.
 
> <snip>
 
Sorry for my english, i will correct some typos, please read again...
 
 
Hello Ben Becarisse,
 
 
Generics are supported by Object Pascal of Delphi and FreePascal
compilers, and what you are doing above with C++ is creating objects of
classes that support generics, so you are passing <int>, that means you
are creating objects that has there elements of type "int"...
generics are also supported by Object Pascal of Delphi and FreePascal
compilers, so what you can do with Delphi and FreePascal is create
objects of datastructures that support generics, in Delphi and
FreePascal we have for example the TList datastructure that supports
generics..
 
So we create an Object of TList datastructure using generics as follow
in Object Pascal of the Delphi and FreePascal compilers:
 
var
Item: Integer;
[1] List: TList<Integer>;
 
....
[2] for Item in List do
Writeln(Item);
 
 
As in C++, in the Object Pascal code above, notice that in [1] we are
creating an object of class Tlist that supports generics, and in [2],
like in C++, we are using the "for" loop to go through
the elements of the Tlist, this will work with the Object Pascal of the
Delphi and FreePascal compilers.. and you can easily find libraries of
Object Pascal in internet that support classes that support generics
and you can do the same as you are doing with C++...so as you have
noticed, the Object Pascal of the Delphi and FreePascal are powerful,
they can support generics, and they even support also Lambda expressions
to express more your program in a functional manner ...
 
 
 
Thank you,
Amine Moulay Ramdane.
Ramine <ramine@1.1>: Feb 25 02:27PM -0800

Hello,
 
I am not interrested in C and C++ because C and C++ are rude and harsh
and difficult, they look like you guys of this C and C++ newsgroups, C
and C++ ressemble ISIS of Irak, C and C++ are savages like islamists of
ISIS in Irak.
 
 
Thank you,
Amine Moulay Ramdane.,
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

No comments: