Skip to content

Commit 795dc6c

Browse files
authored
Merge pull request #3300 from Kaiepi/sigiled-methods
Document sigiled method calls
2 parents 6d5adef + 9cd4c4d commit 795dc6c

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

doc/Language/objects.pod6

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,30 @@ separated by a colon, the arguments: C<method invocant: arguments>. We can use
319319
this syntax whenever it feels more natural than the classical
320320
period-and-parentheses one. It works exactly in the same way.
321321
322+
Note how the call to the C<notes> method in the C<Str> method is made on
323+
C<self>. Writing method calls this way will leave the return value of
324+
the method as is with regards to containers. To containerize return
325+
values, you can make method calls on a sigil instead of C<self>. This
326+
calls various methods on the return value of the method depending on the
327+
sigil used to containerize it:
328+
329+
=begin table
330+
Sigil | Method
331+
==============
332+
$ | item
333+
@ | list
334+
% | hash
335+
& | item
336+
=end table
337+
338+
For example, the C<Str> method of C<Journey> can be rewritten not to use
339+
the C<~> operator by embedding a sigiled method call in the string it
340+
returns:
341+
342+
=begin code :skip-test<demonstrates another way of writing a method>
343+
method Str { ⤷ $!origin\n$ⲧ$.notes()$!destination ⤶\n" }
344+
=end code
345+
322346
Method names can be resolved at runtime with the C<.""> operator.
323347
324348
=begin code

xt/words.pws

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ deopts
293293
deparse
294294
deprecations
295295
deps
296+
dequeue
296297
deref
297298
dereference
298299
dereferenced
@@ -353,6 +354,7 @@ endnetent
353354
endprotoent
354355
endpwent
355356
endservent
357+
enqueue
356358
enqueues
357359
entrapments
358360
ents

0 commit comments

Comments
 (0)