From 3f9fb049b4769e3ad271cf372773ce5dd743e14c Mon Sep 17 00:00:00 2001 From: "Documenter.jl" Date: Fri, 15 Nov 2024 15:10:20 +0000 Subject: [PATCH] build based on 86d931e --- previews/PR116/.documenter-siteinfo.json | 2 +- previews/PR116/index.html | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/previews/PR116/.documenter-siteinfo.json b/previews/PR116/.documenter-siteinfo.json index 0dbaa72..244376a 100644 --- a/previews/PR116/.documenter-siteinfo.json +++ b/previews/PR116/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.11.1","generation_timestamp":"2024-11-14T18:11:56","documenter_version":"1.8.0"}} \ No newline at end of file +{"documenter":{"julia_version":"1.11.1","generation_timestamp":"2024-11-15T15:10:14","documenter_version":"1.8.0"}} \ No newline at end of file diff --git a/previews/PR116/index.html b/previews/PR116/index.html index 4edd262..64be5d0 100644 --- a/previews/PR116/index.html +++ b/previews/PR116/index.html @@ -206,11 +206,11 @@ expr_type, " expression:\n", " $e\n") end -end

Inspiration

The following pages on pattern matching in scala provided inspiration for the library:

The following paper on pattern-matching inspired the automaton approach to code generation:

API Documentation

Match.MatchFailureType
MatchFailure(value)

Construct an exception to be thrown when a value fails to match a pattern in the @match macro.

source
Match.extractMethod
extract(T::Type, value)

Implement extractor for type T, returning a tuple of fields of value, or nothing if the match fails. This can be used to override matching on type T. If extract(T, value) returns a tuple, it will be used instead of the default field extraction.

source
Match.match_fieldnamesMethod
match_fieldnames(type::Type)

Return a tuple containing the ordered list of the names (as Symbols) of fields that can be matched either nominally or positionally. This list should exclude synthetic fields that are produced by packages such as Mutts and AutoHashEqualsCached. This function may be overridden by the client to hide fields that should not be matched.

source
Match.@__match__Macro

Usage:

    @__match__ value begin
+end

Inspiration

The following pages on pattern matching in scala provided inspiration for the library:

The following paper on pattern-matching inspired the automaton approach to code generation:

API Documentation

Match.MatchFailureType
MatchFailure(value)

Construct an exception to be thrown when a value fails to match a pattern in the @match macro.

source
Match.extractMethod
extract(T::Type, value)

Implement extractor for type T, returning a tuple of fields of value, or nothing if the match fails. This can be used to override matching on type T. If extract(T, value) returns a tuple, it will be used instead of the default field extraction.

source
Match.match_fieldnamesMethod
match_fieldnames(type::Type)

Return a tuple containing the ordered list of the names (as Symbols) of fields that can be matched either nominally or positionally. This list should exclude synthetic fields that are produced by packages such as Mutts and AutoHashEqualsCached. This function may be overridden by the client to hide fields that should not be matched.

source
Match.@__match__Macro

Usage:

    @__match__ value begin
         pattern1 => result1
         pattern2 => result2
         ...
-    end

Return result for the first matching pattern. If there are no matches, throw MatchFailure. This uses a brute-force code gen strategy, essentially a series of if-else statements. It is used for testing purposes, as a reference for correct semantics. Because it is so simple, we have confidence about its correctness.

source
Match.@ismatchMacro
@ismatch value pattern

Return true if value matches pattern, false otherwise. When returning true, binds the pattern variables in the enclosing scope.

See also @match for the syntax of patterns

Examples

julia> struct Point
+    end

Return result for the first matching pattern. If there are no matches, throw MatchFailure. This uses a brute-force code gen strategy, essentially a series of if-else statements. It is used for testing purposes, as a reference for correct semantics. Because it is so simple, we have confidence about its correctness.

source
Match.@ismatchMacro
@ismatch value pattern

Return true if value matches pattern, false otherwise. When returning true, binds the pattern variables in the enclosing scope.

See also @match for the syntax of patterns

Examples

julia> struct Point
             x
             y
         end
@@ -224,7 +224,7 @@
 On the y axis at y = 3

Guarded patterns ought not be used with @ismatch, as you can just use && instead:

julia> if (@ismatch p Point(x, y)) && x < y
             println("The point (", x, ", ", y, ") is in the upper left semiplane")
         end
-The point (0, 3) is in the upper left semiplane
source
Match.@matchMacro
@match pattern = value
+The point (0, 3) is in the upper left semiplane
source
Match.@matchMacro
@match pattern = value
 @match value begin
     pattern1 => result1
     pattern2 => result2
@@ -286,7 +286,7 @@
 
 julia> f(Foo(2, "not a foo"))
 ERROR: MatchFailure(Foo(2, "not a foo"))
-...
source
Match.@match_failMacro
@match_fail

Inside the result part of a @match case, you can cause the pattern to fail (as if the pattern did not match).

Examples

julia> struct Vect
+...
source
Match.@match_failMacro
@match_fail

Inside the result part of a @match case, you can cause the pattern to fail (as if the pattern did not match).

Examples

julia> struct Vect
            x
            y
        end
@@ -309,7 +309,7 @@
 Vect(0.5547001962252291, 0.8320502943378437)
 
 julia> norm(Vect(0, 0))
-Vect(0, 0)
source
Match.@match_failMacro
@match_fail

This statement permits early-exit from the value of a @match case. The programmer may write the value as a begin ... end and then, within the value, the programmer may write

@match_fail

to cause the case to terminate as if its pattern had failed. This permits cases to perform some computation before deciding if the rule "really" matched.

source
Match.@match_returnMacro
@match_return value

Inside the result part of a @match case, you can return a given value early.

Examples

julia> struct Vect
+Vect(0, 0)
source
Match.@match_failMacro
@match_fail

This statement permits early-exit from the value of a @match case. The programmer may write the value as a begin ... end and then, within the value, the programmer may write

@match_fail

to cause the case to terminate as if its pattern had failed. This permits cases to perform some computation before deciding if the rule "really" matched.

source
Match.@match_returnMacro
@match_return value

Inside the result part of a @match case, you can return a given value early.

Examples

julia> struct Vect
            x
            y
        end
@@ -332,4 +332,4 @@
 Vect(0.5547001962252291, 0.8320502943378437)
 
 julia> norm(Vect(0, 0))
-Vect(0, 0)
source
Match.@match_returnMacro
@match_return value

This statement permits early-exit from the value of a @match case. The programmer may write the value as a begin ... end and then, within the value, the programmer may write

@match_return value

to terminate the value expression early with success, with the given value.

source
+Vect(0, 0)source
Match.@match_returnMacro
@match_return value

This statement permits early-exit from the value of a @match case. The programmer may write the value as a begin ... end and then, within the value, the programmer may write

@match_return value

to terminate the value expression early with success, with the given value.

source