From 360ef6ea205131703ca4f1cf87d45442f6c97865 Mon Sep 17 00:00:00 2001 From: kjnilsson Date: Thu, 7 Dec 2017 18:33:03 -0800 Subject: [PATCH] send should return unit. fez_unit -> unit --- src/Fez.Core.erl | 3 ++- src/fez.core/core.fs | 3 +++ src/fez/Compiler.fs | 17 ++++++----------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/Fez.Core.erl b/src/Fez.Core.erl index a5cb24d..ea3ab82 100644 --- a/src/Fez.Core.erl +++ b/src/Fez.Core.erl @@ -21,7 +21,8 @@ spawn(F) -> erlang:spawn(F). 'op_LessBang'() -> fun (Dst) -> fun (Msg) -> - Dst ! Msg + Dst ! Msg, + unit end end. diff --git a/src/fez.core/core.fs b/src/fez.core/core.fs index a64bd63..360d3e2 100755 --- a/src/fez.core/core.fs +++ b/src/fez.core/core.fs @@ -32,6 +32,9 @@ let spawn (f : unit -> unit) : Pid = let self () = P let send<'T> (dst: Pid) (msg: 'T) : unit = + // in erlang `send` returns the msg + // in fsharp this would just cause a warning so we + // just return unit instead () let ( + | cerl.Exp (cerl.Constr (cerl.Lit (cerl.LAtom (cerl.Atom "unit")))) -> Some e | _ -> None @@ -450,7 +450,7 @@ module Compiler = | :? string as s -> litString s | :? bool as b -> litAtom (toLowerString b) | null -> //unit - litAtom "fez_unit" //Special casing a value here for unit for now + litAtom "unit" //Special casing a value here for unit for now | x -> failwithf "mapConst: not impl %A" x let ioLibFormat nm str t args = @@ -608,17 +608,12 @@ module Compiler = //method on type rather than nested module fe.LogicalName + "." + f.LogicalName //add callee as first arg if method dispatch - //TODO: refactor - stale let args, nm = let args, nm = eraseUnit exprs |> foldNames nm processExpr let args = args |> stripFezUnit |> List.map (flattenLambda []) - match callee with - | Some o -> - let o, nm = processExpr nm o - o :: args, nm - | None -> args, nm + args, nm let numArgs = List.length args let func, nm = mkFunction nm name numArgs let func = func |> cerl.Fun |> constr @@ -629,7 +624,7 @@ module Compiler = let args, nm = eraseUnit exprs |> foldNames nm processExpr - // remove fez_unit + // remove unit // flatten any lambda args let args = args |> stripFezUnit |> List.map (flattenLambda []) let m = fe.FullName |> safeAtom @@ -1057,7 +1052,7 @@ process dictionary call the Ref.release() method. | B.Lambda (IsUnitArg p, expr) -> let unitName, nm = safeVar true nm p.LogicalName let body, nm = processExpr nm expr - // wrap body in let so that unit arg is mapped to fez_unit + // wrap body in let so that unit arg is mapped to unit let body = mkLet unitName fezUnit body |> constr cerl.Lambda ([], body) |> constr, nm | B.Lambda (p, expr) ->