Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 12 years ago.
Improve this question
Is there (or was there ever) any non-trivial language that allows spaces in its variable names?
I am aware of the language Whitespace, but I'm interested in a language that was actually used for something besides demonstration.
I ask this out of pure curiosity.
In a way, yes. Several languages's variable names are really just keys to a higher-level object. Both Coldfusion and Javascript come to mind. In Javascript, you can write foo=bar, but what you've really said is:
window['foo'] = bar;
You could just as easily write
window['i haz a name'] = bar;
The various scopes in Coldfusion can also be treated as either a (dict|hash|associative array) or a name.
Of course, once you've created a name with whitespace, it's harder to access without using the hash lookup syntax.
TSQL will allow you to use whitespace in table and column names aslong as you have it between square braces [ ]
Theres a fantastic article on just what sql will let you get away with here http://www.sqlservercentral.com/blogs/philfactor/archive/2009/08/14/evil-code.aspx
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 months ago.
Improve this question
I would like to find a clear way to demonstrate concretely that a variable of type string holds a 2-words data structure (at least as far as I understand it).
This demonstration is for didactic purposes.
So, as I know, a string is a 2 words data structure where one word holds the address of the underlying slice of bytes and the word holds the length.
Given a variable defined like this a := "a string literal", is there a way to view (or print) the content of the variable in its 2 words format so that people can actually see this 2-words structure?
is there a way to view (or print) the content of the variable in its 2 words format?
No, because this is an unspecified implementation detail.
If you are okay with code that might brake: Use reflect.StringHeader. See unsafe.Pointer point (6) on how to do this.
Best not to do this. As said: this is a deliberately hidden implementation detail.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
The community reviewed whether to reopen this question 1 year ago and left it closed:
Original close reason(s) were not resolved
Improve this question
One of the ways to write a multi-line string in Ruby is the "here document", or "heredoc", with syntax like:
<<~HEREDOC
My multi-line string
literal goes here!
HEREDOC
My understanding is that any identifier (word) can be used in place of where HEREDOC was used in the above example. (It doesn't have to be the word HEREDOC.)
Is there a documented best practice -- for code readability, and conformity to standards -- for choosing the name to use in a heredoc declaration?
Observations I've made:
The official documentation (as of Ruby v3.0) doesn't seem to advocate any particular best practice. It just states:
You may use any identifier with a heredoc, but all-uppercase identifiers are typically used.
The word SQL seems common when defining a SQL statement -- regardless of the purpose of the statement.
Code examples (including in the official documentation, and in the canonical StackOverflow question on multi-line strings in Ruby linked above) often use HEREDOC, or EOS (presumably meaning "end-of-string" -- even though the identifier appears both at the beginning and end of the string literal).
Sometimes, a word describing the value being stored is used as the heredoc identifier -- as is typically done when declaring a standard variable.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I have strings like:
NoMethodError: undefined method 'sort_by!' for #<Hash:0x00007f98f03c84e0>
These strings can contain n number of such parts: <Hash:0x00007f98f03c84e0>.
Here, 0x00007f98f03c84e0 is just a placeholder of memory reference. And also Hash is type of object of which this memory reference is. There is no need to discuss how these strings got formed but in the end i have strings which can have anything like <ClassName:MEM_REF> and i have to replace MEM_REF part.
Going back to my original example, I want to remove this memory ref part 0x00007f98f03c84e0 with any string of my liking. Again, 0x00007f98f03c84e0 is an example, it will be any arbitrary memory address.
Looking for an elegant way of doing this in ruby.
Try following regex in ruby console, should work: /:[0-9]x[0-9A-Za-z]*(?=>)/.
And to mask these refs with anything else, try input_string.gsub!(/:[0-9]x[0-9A-Za-z]*(?=>)/, "REPLACE_TEXT")
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Is it possible to write custom expansion hooks in bash, just like what bash does for {a..b}? I want to implement a capability to expand/manipulate square brackets [content] and the content inside that. I want all the existing scripts/commands to work as-is
No, bash does not support this feature.
While it's not inconceivable that a version of bash could be written that allows some sort of custom parsing hooks, [...] would be a bad choice since square brackets are already used as a synonym for the test command and for regular expression bracket expressions (i.e., [ab]cd to match either acd or bcd). You would be hard pressed to define another use for square brackets alone that don't interfere with these existing uses. (Although it's not impossible, as the obsolete $[...] notation for arithmetic expressions shows.)
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
In API documentation, and sometimes even used in discussions here on Stack Overflow, I sometimes see the pound (#) character used instead of the dot (.) as the separator between the class name and the method name. For example:
Settings#maxPageSize
I'm wondering what this usage means, and where it comes from?
Assuming you mean Ruby (which is the first language that I can think of with such conventions), it is explained here:
Why are methods in Ruby documentation preceded by a hash sign?
I've always thought that the distinction is that Settings.maxPageSize seems to imply that you can actually write just that (i.e. that it is a static method), and that the pound is there to denote that it is just a reference to a method, not a piece of code that you can execute.
Although I could be totally wrong about this =)
So for static methods, you could actually reference them Settings.maxPageSize, but for instance methods, you'd have the option of coming up with a new convention, such as Array#sort to denote that something special is going on, or, to achieve the same completeness, you'd have to write
myArray.sort // when myArray is of the type Array
EDIT
Amadan's reply seems to confirm my interpretation, with the exception that Settings.maxPageSize is not used for static methods either; rather, that would be Settings::maxPageSize, and . being reserved entirely for example code, which makes sense to me.