Low level programming in ada. Capture a signal,
https://gitlab.com/alaindevos/adatut/-/tree/main/11_signal/src?ref_type=heads
https://gitlab.com/alaindevos/adatut/-/tree/main/11_signal/src?ref_type=heads
Ada its quite easy:One simple example . In C you can dereference a null pointer & a pointer pointing to the sky. Never possible in F# or ada
with Ada.Text_IO;
procedure Erroneous is
type Int_Ptr is access Integer;
P : Int_Ptr; -- uninitialized
begin
-- ERRONEOUS EXECUTION
Ada.Text_IO.Put_Line (Integer'Image (P.all));
end Erroneous;
open Microsoft.FSharp.NativeInterop
#nowarn "9" // allow NativePtr usage
let demo () =
// Allocate stack memory for an int, but DO NOT initialize it
let p = NativePtr.stackalloc<int> 1
// ERRONEOUS / UNDEFINED BEHAVIOR
let x = NativePtr.read p
printfn "%d" x
demo ()
Ada its quite easy:
Code:with Ada.Text_IO; procedure Erroneous is type Int_Ptr is access Integer; P : Int_Ptr; -- uninitialized begin -- ERRONEOUS EXECUTION Ada.Text_IO.Put_Line (Integer'Image (P.all)); end Erroneous;
F# is just .NET so the typical bindings marshal errors allow it too.
Code:open Microsoft.FSharp.NativeInterop #nowarn "9" // allow NativePtr usage let demo () = // Allocate stack memory for an int, but DO NOT initialize it let p = NativePtr.stackalloc<int> 1 // ERRONEOUS / UNDEFINED BEHAVIOR let x = NativePtr.read p printfn "%d" x demo ()
And since languages other than C or C++ need a *shedload* of bindings, this kind of dangerous stuff is very easy (and necessary) to creep in.
String: type == std::string;
auto& Cout = std::cout;
#define Format std::format
greet: (name: String) = {
Cout << Format("Hello, {}\n", name);
}
sum: (a: i32, b: i32) -> i32 = {
sum := a + b; // Type inference with :=
return sum;
}
main: () = {
x: String = "world";
greet(x);
s:=sum(10, 20);
Cout << Format("Sum : {}\n", s);
}
I like it to an extent. I do think extensions of C (and C++) do have a lot of merit as a solution for a next gen language.What do you think of my cppfront program , hello.cpp2 ,
And you miss to name those things that you regard as important.... and miss the important things that need to be improved.
The limitations of C++ are well cited in a number of papers. I don't expect every technical conversation needs to be suitable for kids.And you miss to name those things that you regard as important.
Think about all these kids reading here ... do you think that they know??![]()