-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing regex globals $` and $' #1202
Comments
I opened a PR to add If that's merged, you could use something like As an aside, this question would be rather cryptic to anyone who doesn't already know about Ruby's regexp globals, since they're neither self-explanatory nor googleable. I only know |
Does crystal really want to support all those weird global variables? I'd prefer it'd rather not... possibly not any, I think it leads to bad style. |
@bjmllr thank you. How would I go about merging your fix into my local copy of the source on my hard drive? @PragTob The question is less "should we have global variables" and more "shouldn't there be some way to get this information". It doesn't really matter how you query the data (although personally I like Ruby's special global a), just that you can. |
Globals, I meant. Not global a. Stupid phone. |
I would prefer to see even @stugol Using git, you can add my fork as a remote and then pull my feature branch into a local branch. |
in Ruby $~, $1, $2 etc aren't true global variables. they act as pseudo global variables which means they aren't even thread local but more like a local variable that can come and go. |
@strcmp Thanks for the correction. I guess the only reason to eliminate them would be for style, then. |
yes many people consider them to be a perlism that should be replaced with something else like Regexp.last_match (it has same semantics as $~). |
Crystal already has chosen to emit |
The use case is "case", but I'm honestly not sure it's worth all the trouble. At least they are concurrency safe. |
why is case the use case? Can't you do (didn't check code for correctness):
what am I missing? |
Try handling more than one regex and getting the captured groups in each case. Sorry, I can't code from a cellphone |
Ah I see, thanks for explaining @asterite ! |
They have even less value if you admit crystal is probably not going to be used for one-liners (where they do make sense) ;-). |
I think these pseudo-globals have a definite use. |
Why not just add |
Do |
@bjmllr I can't compile your changes. An attempt to
I previously compiled the project without issue. |
Also I'll be damned if I can get my head around the use of git.
Dammit, why does everything have to be so complicated? Also, why did these commands work last time, and don't work now?? |
@stugol, the linker isn't able to find PCRE on your system. FWIW I didn't touch the C bindings. |
Well someone did. And I can't install PCRE because I have no way of knowing which PCRE is required. On my Debian box, the options are:
|
Use |
Would it be too much trouble for the code to actually compile, please?
|
Download the Boehm GC yourself, install it, and delete the |
For the others, the library used for coroutines (forgot the name!) is also too old. Build and install it manually. I love Ubuntu, but the packages can get pretty old sometimes. :) |
Wait... I have to download and build two other programs that I've never even heard of, before I can build the latest version of Crystal? But I managed to build whatever the current version was three days ago with no problems. What's changed? Where does this end? Suppose these other things require further dependencies? Debian has a package manager for a reason. If I go compiling stuff from source all over the place, I'm going to bork my installation. Again. It worked three days ago. Why can't it just work now? |
not need to build this libs, just set LIBRARY_PATH to downloaded crystal. |
@stugol right now when you install Crystal from .deb package for instance, it also comes with some precompiled binaries of the dependencies (in the future, custom packages for each distribution might be created). If you use the "crystal" wrapper installed by the package, it will add the libraries to the LIBRARY_PATH, so it should work. I'm not sure what's going on in your setup. Please, try running "make clean" first. No dependencies has changed in many days. Most dependencies from Debian should serve the purpose for building Crystal. Some distros doesn't include recent enough versions of LLVM, libpcl and Boehm GC. |
Seems the problem is caused by replacing the distro version of Crystal with the freshly-compiled version. Attempting to compile Crystal with a freshly-compiled Crystal fails. |
@bjmllr Also, I don't know how to pull your regex changes without pulling your entire fork. And your fork is massively outdated, according to the page. I really don't know what I'm doing with git. |
Can we please stay on topic here and move setup/configuration problems to a separate thread? |
#1207 is merged, I vote against adding more (pseudo) globals than necessary. Can we close this? |
I personally would prefer to use the Ruby-style pseudo-globals, if you're asking for votes... |
@jhass Yes, we can close this, we can do |
I use the regex globals$` and $ ' in Ruby. What is the Crystal alternative to these?
The text was updated successfully, but these errors were encountered: