Skip to content

Instantly share code, notes, and snippets.

View raph-amiard's full-sized avatar

Raphaël AMIARD raph-amiard

View GitHub Profile

Subject: A Farewell to Ada with null Date: Fri, 20 Nov 92 00:51:25 EST From: Jean D Ichbiah ichbiah@ajpo.sei.cmu.edu

From: Jean D Ichbiah To: Chris Anderson cc: DRs, VRs, Iso [other Adaphiles]

A Farewell to Ada with null

------------------------------
-- Formal functions version --
------------------------------
generic
type T is private;
-- PRO & CON: Interface is implicit & not named. Less typing to do.
with function Hash (Self : T) return Hash_Type is <>;
package Hash_Tables
...
procedure Teststpr is
type Kind is (A, B, C, D);
Lol : constant := 12;
subtype Subkind is Kind
with Static_Predicate => Subkind = A or else (Lol > 20 and then Subkind = D);
-- WHAT THE ACTUAL FUCK
type Rec (K : Kind) is record
with Ada.Text_IO; use Ada.Text_IO;
procedure Numval is
type Enum is (A, B, C, D, E, F);
L : Integer := Enum'Pos(Enum'Last) - Enum'Pos(Enum'First);
begin
Put_Line (L'Image);
end Numval;
"""
This module implements a record facility in Python. The aim is to simplify the
case where you want a simple data class, which is used mainly to store data,
and you don't want to implement the regular python boilerplate of:
* Assigning fields in the constructors
* Sanity checking number of arguments, types, optional or not, etc
* Implementing repr
* Implementing hash and structural equality (not yet implemented)
INT_TYPES = (SignedIntTypeDef, ModIntTypeDef)
FLOAT_TYPES = (FloatingPointDef, OrdinaryFixedPointDef,
DecimalFixedPointDef)
@extend(CharLiteral)
class _:
name = Property(Self.tok)
// Ewwww
NVGpaint shadowPaint = nvgBoxGradient(mCtx, left + shadow.d_xpos - shadow.d_spread, top + shadow.d_ypos - shadow.d_spread, width + shadow.d_spread * 2.f, height + shadow.d_spread * 2.f, c0 + shadow.d_spread, shadow.d_blur, nvgRGBA(0, 0, 0, 128), nvgRGBA(0, 0, 0, 0));
// What's so wrong about
NVGpaint shadowPaint = nvgBoxGradient(
mCtx,
left + shadow.d_xpos - shadow.d_spread,
top + shadow.d_ypos - shadow.d_spread,
with Ada.Strings.Hash;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Containers.Indefinite_Hashed_Maps;
with Ada.Text_IO; use Ada.Text_IO;
procedure Eval is
package String_Maps is new Ada.Containers.Indefinite_Hashed_Maps
(String, Integer, Hash => Ada.Strings.Hash, Equivalent_Keys => "=");
function "+" (S : String) return Unbounded_String renames To_Unbounded_String;
package body Foo is
procedure T is
B : Float;
type Proc_Access is access procedure (A : Integer);
pragma Convention (C, Proc_Access);
procedure Pouet (A : Integer);
pragma Convention(C, Pouet);
function run_async_sleep(action_fn) {
wait_times = action_fn()
function internal() {
try {
wait_time = wait_times.next()
} catch (_) {
return;
}
if (wait_time) {
setTimeout(internal, wait_time);