Re: Re: Opinion on Pascal
By: Hemo to Jagossel on Fri Mar 31 2017 10:52 pm
> -=> Jagossel wrote to Hemo <=-
>
> Ja> Re: Re: Opinion on Pascal
> Ja> By: Hemo to jagossel on Thu Mar 30 2017 22:32:01
>
> > I would never consider Bash a programming language any more than I would
> > DOS
>
> Ja> No argument from me on that point. I get it's not a programming
> Ja> language in the fact that there is no code to compile. I never said
> Ja> that it is a programming language.
>
> > But.. as a scripting language, it is similar to a programming language in
> > th
> Ja> at
> > is has specific syntax for specific commands. If you don't get the
> > syntax correct, you're screwed no matter what language you're working in.
>
> Ja> I totally get that. My point is that other languages (both scrpting and
> Ja> programmimg languages) have SOME room for minor differenes in
> Ja> whitespacing.
>
> Ja> Again, I have VERY LITTLE experience with BASH and I get tripped up
> Ja> from time to time when I do use it and I have to look up some things in
> Ja> the manual.
>
> Ja> Examples of where I stumbled a bit:
> Ja> - Spaces inside the square brackets
> Ja> - The special switches for if a directory or file exists or doesn't
> Ja> exist
> Ja> - Accepting argumemts
> Ja> - Defining functions first before calling it
>
>
> no arguments from me on any of that. I find the more languages one tries to
> learn, the more confusing it can be as things do vary between them.
> Sometimes quite a bit. Sometimes little things, like the result when
> comparing strings. C returns 0 when they match, which still trips me up,
> becuase most other languages I may use return 1 or true when strings match.
But you're referring to strcmp(), which is just one string comparison function.
You could write your own that returned a boolean value very easily:
bool strings_match(const char* str1, const char* str2) {
return strcmp(str1, str2) == 0;
}
... or actuall compare each character in the string and return whatever you
like.
But the whole reason that strcmp() returns an integer (and not a boolean) is
because it tells the caller (you) which string is "greater" (for sorting
purposes), which can be very handy indeed (e.g. if < 0, then str1 is less than
str2). So it does more than just tell if you 2 strings match, it tells you how
the 2 strings compare with eachother.
digital man
Synchronet "Real Fact" #83:
Donations to the Synchronet project are welcome @ http://wiki.synchro.net/donate
Norco, CA WX: 74.0°F, 29.0% humidity, 15 mph ESE wind, 0.00 inches rain/24hrs
---
■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ telnet://vert.synchro.net
|