-
Notifications
You must be signed in to change notification settings - Fork 98
/
Macros.jl
68 lines (58 loc) · 1.4 KB
/
Macros.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
"""
@abstractmethod
Macro used in generic functions that must be overloaded by derived types.
"""
macro abstractmethod(message="This function belongs to an interface definition and cannot be used.")
quote
error($(esc(message)))
end
end
"""
@notimplemented
@notimplemented "Error message"
Macro used to raise an error, when something is not implemented.
"""
macro notimplemented(message="This function is not yet implemented")
quote
error($(esc(message)))
end
end
"""
@notimplementedif condition
@notimplementedif condition "Error message"
Macro used to raise an error if the `condition` is true
"""
macro notimplementedif(condition,message="This function is not yet implemented")
quote
if $(esc(condition))
@notimplemented $(esc(message))
end
end
end
"""
@unreachable
@unreachable "Error message"
Macro used to make sure that a line of code is never reached.
"""
macro unreachable(message="This line of code cannot be reached")
quote
error($(esc(message)))
end
end
"""
@check condition
@check condition "Error message"
Macro used to make sure that condition is fulfilled, like `@assert`
but the check gets deactivated when running Gridap in performance mode.
"""
macro check(test,msg="A check failed")
@static if execution_mode == "debug"
quote
@assert $(esc(test)) $(esc(msg))
end
else
quote
nothing
end
end
end