3 ms·
Can you pattern match using variant and use it as a result type, or option type with associated bind, map and other functions?
by UK-Al05 6y ago
Can you pattern match using variant and use it as a result type, or option type with associated bind, map and other functions?
- badsectoracula 6y agoYou can use the variant as a result, yes. It is somewhat like a struct with a tagged union in C. The only functionality standard Pascal offers is the simplest "case" statement where you can match against the variances with only little more functionality than C's select statement (you can have multiple values per case and you can use ranges), but nothing more than that. In modern Object Pascal it might be possible to implement the functionality using generics and anonymous functions (currently only available in Delphi but soon also in Free Pascal), but AFAIK there isn't any functional programming-like functionality out of the box. In general Pascal is largely an imperative programming language and even in the more advanced dialects there is almost no functional programming functionality.