PreviousUpNext

14.4.131  Unsafe

The standard library Unsafe api defines access to various datastructures and functions which by-pass the usual compiler type-safeness guarantees. By using this api, you can write code just as flaky and core-dump prone as any C program! This functionality is occasionally used in truly time-critical code to avoid some runtime checks.

In general the best advice when tempted to use this module is — don’t!

The Unsafe api is implemented by the unsafe package.

The Unsafe api source code is in src/lib/std/src/unsafe/unsafe.api.

The above information is manually maintained and may contain errors.

api {    package mythryl_callable_c_library_interface : api {
                                                       exception CFUN_NOT_FOUND String;
                                                       find_c_function : {fun_name:String,  lib_name:String} -> X -> Y;
                                                       Cfunction ;
                                                       find_cfun : (String , String) -> Cfunction;
                                                       System_Constant  = (Int , String);
                                                       exception SYSTEM_CONSTANT_NOT_FOUND String;
                                                       find_system_constant : (String , List(System_Constant ))
                                                                              -> Null_Or(System_Constant );
                                                       bind_system_constant : (String , List(System_Constant )) -> System_Constant;
                                                   };;
    package unsafe_chunk : api {
                               Chunk ;
                               Representation 
                                 = BYTE_RO_VECTOR
                                 | BYTE_RW_VECTOR
                                 | FLOAT64
                                 | FLOAT64_RW_VECTOR
                                 | LAZY_SUSPENSION
                                 | PAIR
                                 | RECORD
                                 | REF
                                 | TYPEAGNOSTIC_RO_VECTOR
                                 | TYPEAGNOSTIC_RW_VECTOR
                                 | UNBOXED
                                 | UNT1
                                 | WEAK_POINTER;
                               to_chunk : X -> Chunk;
                               make_tuple : List(Chunk ) -> Chunk;
                               boxed : Chunk -> Bool;
                               unboxed : Chunk -> Bool;
                               rep : Chunk -> Representation;
                               length : Chunk -> Int;
                               exception REPRESENTATION;
                               to_tuple : Chunk -> List(Chunk );
                               to_string : Chunk -> String;
                               to_ref : Chunk -> Ref(Chunk );
                               to_rw_vector : Chunk -> Rw_Vector(Chunk );
                               to_float64_rw_vector : Chunk -> ?.rw_vector_of_eight_byte_floats::Rw_Vector;
                               to_byte_rw_vector : Chunk -> ?.rw_vector_of_one_byte_unts::Rw_Vector;
                               to_vector : Chunk -> ?.Vector(Chunk );
                               to_byte_vector : Chunk -> ?.vector_of_one_byte_unts::Vector;
                               to_exn : Chunk -> Exception;
                               to_float : Chunk -> Float;
                               to_int : Chunk -> Int;
                               to_int1 : Chunk -> one_word_int::Int;
                               to_unt : Chunk -> Unt;
                               to_unt8 : Chunk -> one_byte_unt::Unt;
                               to_unt1 : Chunk -> one_word_unt::Unt;
                               nth : (Chunk , Int) -> Chunk;
                           };;
    package software_generated_periodic_events : api {
                                                     exception BAD_SOFTWARE_GENERATED_PERIODIC_EVENT_INTERVAL;
                                                     software_generated_periodic_events_switch_refcell__global : Ref(Bool );
                                                     set_software_generated_periodic_event_handler : Null_Or((fate::Fate(Void ) -> fate::Fate(Void )) )
                                                                                                     -> Void;
                                                     get_software_generated_periodic_event_handler : Void
                                                                                                     -> Null_Or((fate::Fate(Void ) -> fate::Fate(Void )) );
                                                     set_software_generated_periodic_event_interval : Null_Or(Int ) -> Void;
                                                     get_software_generated_periodic_event_interval : Void -> Null_Or(Int );
                                                 };;
    package vector : api {
                         get : (?.Vector(X ) , Int) -> X;
                         make : (Int , List(X )) -> ?.Vector(X );
                     };;
    package rw_vector : api {
                            get : (Rw_Vector(X ) , Int) -> X;
                            set : (Rw_Vector(X ) , Int , X) -> Void;
                            make : (Int , X) -> Rw_Vector(X );
                        };;
    package vector_of_chars : api {
                                  Vector  = Vector;
                                  Element  = Element;
                                  get : (Vector , Int) -> Element;
                                  set : (Vector , Int , Element) -> Void;
                                  make : Int -> Vector;
                              };;
    package rw_vector_of_chars : api {
                                     Rw_Vector  = Rw_Vector;
                                     Element  = Element;
                                     get : (Rw_Vector , Int) -> Element;
                                     set : (Rw_Vector , Int , Element) -> Void;
                                     make : Int -> Rw_Vector;
                                 };;
    package vector_of_one_byte_unts : api {
                                          Vector  = Vector;
                                          Element  = Element;
                                          get : (Vector , Int) -> Element;
                                          set : (Vector , Int , Element) -> Void;
                                          make : Int -> Vector;
                                      };;
    package rw_vector_of_one_byte_unts : api {
                                             Rw_Vector  = Rw_Vector;
                                             Element  = Element;
                                             get : (Rw_Vector , Int) -> Element;
                                             set : (Rw_Vector , Int , Element) -> Void;
                                             make : Int -> Rw_Vector;
                                         };;
    package rw_vector_of_eight_byte_floats : api {
                                                 Rw_Vector  = Rw_Vector;
                                                 Element  = Element;
                                                 get : (Rw_Vector , Int) -> Element;
                                                 set : (Rw_Vector , Int , Element) -> Void;
                                                 make : Int -> Rw_Vector;
                                             };;
    get_handler : Void -> fate::Fate(X );
    set_handler : fate::Fate(X ) -> Void;
    get_current_thread_register : Void -> X;
    set_current_thread_register : X -> Void;
    get_pseudo : Int -> X;
    set_pseudo : (X , Int) -> Void;
    unpickle_datastructure : vector_of_one_byte_unts::Vector -> X;
    pickle_datastructure : X -> vector_of_one_byte_unts::Vector;
    boxed : X -> Bool;
    cast : X -> Y;
    package p : api {
                    Pervasive_Package_Pickle_List 
                      = CONS (vector_of_one_byte_unts::Vector , unsafe_chunk::Chunk
                              , Pervasive_Package_Pickle_List) | NIL;
                };;
    pervasive_package_pickle_list__global : Ref(p::Pervasive_Package_Pickle_List );
    toplevel_fate : Ref(fate::Fate(Void ) );
    posix_interprocess_signal_handler_refcell__global : Ref(((Int , Int , fate::Fate(Void ))
                                                             -> fate::Fate(Void )) );
};


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext