(*** Exercice 1 ***) aspect PinceCoupante { pointcut tournevis(): execution(* Tournevis.*(..)); before() : tournevis() { System.out.println("Advice from : " + thisJoinPointStaticPart.getSignature().getName()); }} final static boolean ENABLED = true; pointcut marteau() : if (PinceCoupante.ENABLED) && // ... (*** Exercice 2 ***) (*** Exercice 3 ***) (*** Exercice 4 ***) module type STORAGE = sig type resource = string type t exception NotEnoughResource of resource val new_storage : unit -> t val add_resource : t -> resource -> int -> unit val remove_resource : t -> resource -> int -> unit end module S:STORAGE = struct type resource = string type t = (resource, int) Hashtbl.t exception NotEnoughResource of resource let new_storage () = Hashtbl.create 10 let add_resource t r i = try let c = Hashtbl.find t r in Hashtbl.replace t r (c+i) with Not_found -> Hashtbl.add t r i let remove_resource t r i = try let c = Hashtbl.find t r in if (c >= i) then Hashtbl.replace t r (c-i) else raise (NotEnoughResource r) with Not_found -> raise (NotEnoughResource r) end let t = S.new_storage();; S.add_resource t "Cranberry" 3;; S.remove_resource t "Cranberry" 1;; S.remove_resource t "Cranberry" 2;; S.remove_resource t "Cranberry" 1;; (* Raises NotEnoughResource "Cranberry" *)