Skip to main content
added 72 characters in body
Source Link

Re 1: As documented in tutorial/OperatorInputFormsOperator Input Forms, colon represents two different operations:

symb:expr Pattern[symb, expr] patt:expr Optional[patt, expr] 

If you look at the FullFormFullForm of your first three examples, you'll see that they follow these forms. The fourth example arguably is a bug.

Re 2) No, opts:OptionsPattern[] is not a special fromform. From the rules given above, rules opts: OptionsPattern[] is the first case, assigning the pattern OptionsPattern[]OptionsPattern[] to the symbol optsopts. OptionsPattern[] is itself a particular kind of pattern, just like _, Except, and KeyValuePattern are particular kinds of patterns. What sets it slightly apart from other patterns is that it sets up special rules for using OptionValue on the RHS of the rule.

More generally, about a year and half ago (so I think for 10.4), I got so fed up with the documentation of OptionsPattern and OptionsValue that I led a mini project to completely rewrite their pages. I think reading both the details and the new examples will give you a lot more insight into this idiom.

Re 1: As documented in tutorial/OperatorInputForms, colon represents two different operations:

symb:expr Pattern[symb,expr] patt:expr Optional[patt,expr] 

If you look at the FullForm of your first three examples, you'll see that they follow these forms. The fourth example arguably is a bug.

Re 2) No, opts:OptionsPattern[] is not a special from. From the rules given above, rules opts: OptionsPattern[] is the first case, assigning the pattern OptionsPattern[] to the symbol opts. OptionsPattern[] is itself a particular kind of pattern, just like _, Except, and KeyValuePattern are particular kinds of patterns. What sets it slightly apart from other patterns is that it sets up special rules for using OptionValue on the RHS of the rule.

More generally, about a year and half ago (so I think for 10.4), I got so fed up with the documentation of OptionsPattern and OptionsValue that I led a mini project to completely rewrite their pages. I think reading both the details and the new examples will give you a lot more insight into this idiom.

Re 1: As documented in Operator Input Forms, colon represents two different operations:

symb:expr Pattern[symb, expr] patt:expr Optional[patt, expr] 

If you look at the FullForm of your first three examples, you'll see that they follow these forms. The fourth example arguably is a bug.

Re 2) No, opts:OptionsPattern[] is not a special form. From the rules given above, rules opts: OptionsPattern[] is the first case, assigning the pattern OptionsPattern[] to the symbol opts. OptionsPattern[] is itself a particular kind of pattern, just like _, Except, and KeyValuePattern are particular kinds of patterns. What sets it slightly apart from other patterns is that it sets up special rules for using OptionValue on the RHS of the rule.

More generally, about a year and half ago (so I think for 10.4), I got so fed up with the documentation of OptionsPattern and OptionsValue that I led a mini project to completely rewrite their pages. I think reading both the details and the new examples will give you a lot more insight into this idiom.

edited body
Source Link
Jason B.
  • 72.3k
  • 3
  • 152
  • 317

Re 1: As documented in tutorial/OperatorInputForms, colon represents two different operations:

symb:expr Pattern[symb,expr] patt:expr Optional[patt,expr] 

If you look at the FullForm of your first three examples, you'll see that they follow these forms. The fourth example arguably is a bug.

Re 2) No, opts:OptionsPattern[] is not a special from. From the rules given above, rules opts: OptionasPattern[]OptionsPattern[] is the first case, assigning the pattern OptionsPattern[] to the symbol opts. OptionsPattern[] is itself a particular kind of pattern, just like _, Except, and KeyValuePattern are particular kinds of patterns. What sets it slightly apart from other patterns is that it sets up special rules for using OptionValue on the RHS of the rule.

More generally, about a year and half ago (so I think for 10.4), I got so fed up with the documenationdocumentation of OptionsPattern and OptionsValue that I led a mini project to completely rewrite their pages. I think reading both the details and the new examples will give you a lot more insight into this idiom.

Re 1: As documented in tutorial/OperatorInputForms, colon represents two different operations:

symb:expr Pattern[symb,expr] patt:expr Optional[patt,expr] 

If you look at the FullForm of your first three examples, you'll see that they follow these forms. The fourth example arguably is a bug.

Re 2) No, opts:OptionsPattern[] is not a special from. From the rules given above, rules opts: OptionasPattern[] is the first case, assigning the pattern OptionsPattern[] to the symbol opts. OptionsPattern[] is itself a particular kind of pattern, just like _, Except, and KeyValuePattern are particular kinds of patterns. What sets it slightly apart from other patterns is that it sets up special rules for using OptionValue on the RHS of the rule.

More generally, about a year and half ago (so I think for 10.4), I got so fed up with the documenation of OptionsPattern and OptionsValue that I led a mini project to completely rewrite their pages. I think reading both the details and the new examples will give you a lot more insight into this idiom.

Re 1: As documented in tutorial/OperatorInputForms, colon represents two different operations:

symb:expr Pattern[symb,expr] patt:expr Optional[patt,expr] 

If you look at the FullForm of your first three examples, you'll see that they follow these forms. The fourth example arguably is a bug.

Re 2) No, opts:OptionsPattern[] is not a special from. From the rules given above, rules opts: OptionsPattern[] is the first case, assigning the pattern OptionsPattern[] to the symbol opts. OptionsPattern[] is itself a particular kind of pattern, just like _, Except, and KeyValuePattern are particular kinds of patterns. What sets it slightly apart from other patterns is that it sets up special rules for using OptionValue on the RHS of the rule.

More generally, about a year and half ago (so I think for 10.4), I got so fed up with the documentation of OptionsPattern and OptionsValue that I led a mini project to completely rewrite their pages. I think reading both the details and the new examples will give you a lot more insight into this idiom.

Fix trivial typos
Source Link
Itai Seggev
  • 14.6k
  • 61
  • 86

Re 1: As documented in tutorial/OperatorInputForms, colon represents two different operations:

symb:expr Pattern[symb,expr] patt:expr Optional[patt,expr] 

If you look at the FullForm of your first three examples, you'll see that they follow these forms. The fourth example arguably is a bug.

Re 2) No, opts:OptionsPattern[] is not a special from. From the rules given above, rules opts: OptionasPattern[] is the first case, assigning the pattern OptionsPattern[] to the symbol opts. OptionsPattern[] is itself a particular kind of pattern, just like _, Except, and KeyValuePattern are particular kinds of patterns. What sets it slightly apart from other patterns is that ttit sets up special rules for using OptionValue on the RHS of the rule.

More generally, about a year and half ago (so I think for 10.4), I got so fed up with the documenation of OptionsPattern and OptionsValue that leadI led a mini project to completelycompletely rewrite their pages. I think reading both the details and the new examples will give you a lot more insight into this idiom.

Re 1: As documented in tutorial/OperatorInputForms, colon represents two different operations:

symb:expr Pattern[symb,expr] patt:expr Optional[patt,expr] 

If you look at the FullForm of your first three examples, you'll see that they follow these forms. The fourth example arguably is a bug.

Re 2) No, opts:OptionsPattern[] is not a special from. From the rules given above, rules opts: OptionasPattern[] is the first case, assigning the pattern OptionsPattern[] to the symbol opts. OptionsPattern[] is itself a particular kind of pattern, just like _, Except, and KeyValuePattern are particular kinds of patterns. What sets it slightly apart from other patterns is that tt sets up special rules for using OptionValue on the RHS of the rule.

More generally, about a year and half ago (so I think for 10.4), I got so fed up with the documenation of OptionsPattern and OptionsValue that lead a mini project to completely rewrite their pages. I think reading both the details and the new examples will give you a lot more insight into this idiom.

Re 1: As documented in tutorial/OperatorInputForms, colon represents two different operations:

symb:expr Pattern[symb,expr] patt:expr Optional[patt,expr] 

If you look at the FullForm of your first three examples, you'll see that they follow these forms. The fourth example arguably is a bug.

Re 2) No, opts:OptionsPattern[] is not a special from. From the rules given above, rules opts: OptionasPattern[] is the first case, assigning the pattern OptionsPattern[] to the symbol opts. OptionsPattern[] is itself a particular kind of pattern, just like _, Except, and KeyValuePattern are particular kinds of patterns. What sets it slightly apart from other patterns is that it sets up special rules for using OptionValue on the RHS of the rule.

More generally, about a year and half ago (so I think for 10.4), I got so fed up with the documenation of OptionsPattern and OptionsValue that I led a mini project to completely rewrite their pages. I think reading both the details and the new examples will give you a lot more insight into this idiom.

added 8 characters in body
Source Link
Itai Seggev
  • 14.6k
  • 61
  • 86
Loading
Source Link
Itai Seggev
  • 14.6k
  • 61
  • 86
Loading