logs archiveBotHelp.net / Freenode / #ada / 2015 / July / 31 / 1
mk270
ok, i have two types called File_Descriptor, in GNAT.OS_Lib and POSIX.IO (from florist)
they are both morally just typedefs for Integer
is it trivial to get the underlying integer out of one, and construct a value of other based on an Integer?
jk4
wow morality
why use two different file descriptors?
mk270
?
do you mean, why use two different types called File_Descriptor?
jk4
"i have two types called File_Descriptor"
mk270
one type is required by the Create_Pipe() fn; the other is required by Spawn ()
yes
they represent the same concept, but they exist in two packages, in two libraries, maintained by different organisations
Visaoni
can you just cast them? otherwise you can probably use Pos and Val, or I guess unchecked_conversion if it came to it
mk270
i have used Pos
but i don't know about Val
maybe Val is the second part of this problem
jk4
they are both based on integer?
Visaoni
they're inverses, basically
mk270
they're both based on integer
one has an explicit range
type File_Descriptor is new Integer;
versus
type File_Descriptor is range 0 .. POSIX.Open_Files_Maxima'Last - 1;
anyway, it is trivial to verify whether it works
as it happens, the actual value of the underlying integer exchanged with the kernel is known at compile time (to be 3 or 4)
so i only need to test those cases :)
jk4
how trusting you are
mk270
i am already testing for the catastrophic case where the values are NOT 3 or 4
so it's completely fine
jk4
Allegra-- probably has something to say about that
Allegra--
My variables hurt. Am I catching a bug?
jk4
!quote
Allegra--
Love truth, and pardon error.
-- Voltaire
mk270
you could contrive that case by running the executable from the shell; we only care about the case where it's run from a CGI server
jk4
thought so
mk270
since it's running under CGI, we're testing a LOT of pathological cases
already
jk4
no doubt
mk270
this thing wants me to give it a System.Address
can I make one of those from a known-length string?
Visaoni
Yep. There is an attribute called Address :)
mk270
is that like
Buffer : String(1 .. 1024); Buffer'Address?
and then be as paranoid as a C programmer?
Visaoni
pretty much
mk270
ok good - thanks
it's nice of Ada to let me do this
OCaml wouldn't be so accommodating :)
Visaoni
Ada is a funny beast
jk4
attribute of being embedded friendly
Visaoni
I think it is lacking some serious escapes when it comes to generic type stuff, but it also gives you an absolute ton of control down at the really low level
jk4
serious escapes?
mk270
awesome - this whole thing works :)
i've invented a ridiculous idiom, too :)
declare
Data : constant String (1 .. Bytes_Read) := Buffer (1 .. Bytes_Read);
begin
....
where bytes_read and buffer are the result of some lightly-wrapped call to read(2)
Visaoni
jk4: er, abilities
mk270
ok - thanks for help!
Visaoni
I understand some of the limitations of existing features, but think there needs to be better support for compile-time type stuff
jk4
thanks mr. obvious
:)
Visaoni
ha
I've just been running into... many/most of those limitations in my latest project. I'm a little sore about it :)
jk4
doubt many mainstream languages will ever have good type systems
Ada's is acceptable
Visaoni
seems to be a little more buzz around stronger type systems these days
maybe we'll see something pop up
jk4
in a novel way only imo
Visaoni
could be
ax_
hello!
Is it fair to say Ada programmers tend to be better paid than other programmers using popular languages because Ada is mainly applied in high-margin lesser-competition kind of applications?
Shark8
ax_: AFAIK, though I haven't really looked at the numbers. (I use Ada *because* of its safety and maintainability features.)
ax_
Shark8, why is it more safe and maintainable? Is this why the military has mandated the use of Ada? Or are there top people in the military who kind of love Ada?
Visaoni
ax_: Ada was developed by(ish)/for the military/DoD, although the days of the mandate are long over
I don't have it on hand but I think some people here probably have some links to a more detailed history
ax_
Visaoni, that's bad. Will that affect job security of ada programmers?
Do Ada programmers need to do formal verification for the military apps?
Visaoni
I have no idea about how widespread the use of Ada in the military is
I think it was somewhat recently used for air traffic control stuff over in the UK
SPARK is... something to Ada that has far more formal verification type stuff built in/required, although I haven't looked at it much
ax_
I'm ignorant. Never even heard of SPARK
any risk that the military will replace Ada with SPARK?
Visaoni
No idea. As I said, not even sure how much Ada is used in military stuff these days
ax_
Just googled SPARK. Code looks rather mathematical to me
Visaoni
If jobs are your focus, I'd probably suggest seeking another language. Doubt there is a ton out there, and if you happen to land a job that does Ada you can always learn it then
ax_
hehe. not just jobs. I'm looking for high-paying jobs:)
Visaoni
Ah, well, afraid I can't help you much there :)
ax_
too much competition with javascript, python programmers. Prefer lesser competition.
Visaoni
Most Ada stuff I've heard of seems to be out in Europe these days
There are a few people here that do work in Ada, and I *think* most of them are out that direction
ax_
ok. thanks for the tip
Shark8
ax_: The more verbose syntax means it's hard to get a mistyped construct to compile, the consistency-checks across packages, the solid (and forced) separation of interface & implementation, (in general) the readability of words instead of symbols. Etc.
Visaoni
You missed him :P
Shark8
Yeah, so I see.
(Was busy elsewhere.)
Visaoni
I'm not sure words are really more readable than symbols once you internalize the symbols. The thing I like the most is that you see a difference in the terminators, so you don't have to rely on code structure or else go searching for the matching open bracket
That said, I have found I now have far less tolerance for wading through code snippets in unfamiliar symbol-heavy languages...
« prev 1 2 3 4 next »