From: Vasilij Schneidermann <mail@vasilij.de>
To: Juri Linkov <juri@linkov.net>
Cc: Lars Ingebrigtsen <larsi@gnus.org>,
Stefan Monnier <monnier@iro.umontreal.ca>,
emacs-devel@gnu.org
Subject: Re: Make regexp handling more regular
Date: Thu, 3 Dec 2020 23:20:30 +0100 [thread overview]
Message-ID: <20201203222030.GG1196@odonien.localdomain> (raw)
In-Reply-To: <87wnxya9il.fsf@mail.linkov.net>
[-- Attachment #1: Type: text/plain, Size: 775 bytes --]
> Notably in Ruby e.g. /(.)(.)(.)/.match("foo") returns a MatchData object:
>
> #<MatchData "foo" 1:"f" 2:"o" 3:"o">
>
> Shouldn't a function like string-match (or rather some new function)
> return a #<MatchData> object too? Or the current list returned
> by the function 'match-data' is sufficient?
Personally I find the pattern of mixing a check for a match object, then
access to the global match variables a lot more convenient in Ruby than
extracting the data from the match object:
'foo123bar'[/[a-z]+([0-9]+)[a-z]+/] && $1 #=> "123"
The alternative:
m = /[a-z]+([0-9]+)[a-z]+/.match('foo123bar')
m && m[1] #=> "123"
The above is more attractive if there was an if-let/when-let
equivalent. So that's what I'd design against.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2020-12-03 22:20 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-02 9:05 Make regexp handling more regular Lars Ingebrigtsen
2020-12-02 10:44 ` Lars Ingebrigtsen
2020-12-02 11:12 ` Stefan Kangas
2020-12-02 11:21 ` Philipp Stephani
2020-12-03 8:31 ` Lars Ingebrigtsen
2020-12-02 17:17 ` Stefan Monnier
2020-12-02 17:45 ` Yuan Fu
2020-12-02 19:24 ` Stefan Monnier
2020-12-03 8:40 ` Lars Ingebrigtsen
2020-12-03 8:38 ` Lars Ingebrigtsen
2020-12-03 15:10 ` Stefan Monnier
2020-12-03 16:58 ` Lars Ingebrigtsen
2020-12-03 17:40 ` Stefan Monnier
2020-12-02 21:19 ` Juri Linkov
2020-12-03 8:41 ` Lars Ingebrigtsen
2020-12-03 15:00 ` Stefan Monnier
2020-12-03 21:02 ` Juri Linkov
2020-12-03 22:20 ` Vasilij Schneidermann [this message]
2020-12-02 21:28 ` Daniel Martín
2020-12-03 4:16 ` Adam Porter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201203222030.GG1196@odonien.localdomain \
--to=mail@vasilij.de \
--cc=emacs-devel@gnu.org \
--cc=juri@linkov.net \
--cc=larsi@gnus.org \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).