« first day (2072 days earlier)      last day (2852 days later) » 

12:46 AM
@Cerberus variables are things that hold data. An object can have variables in it (member variables). A variable can hold an object.
Wow this is my first time using the improved mobile chat ui. It's nice.
 
So a variable can hold an object, and an object can hold a variable.
And arrays can also hold variables, I believe?
 
I believe I was accused of making pseudo-arrays once.
 
So a simple matter variable might be a single number. A structure is a collection of related variables in one place, like an address. Semantically it is treated as a single variable. An object is a structure with functions that operate on it.
@Cerberus yes you were.
 
1:05 AM
@Mr.ShinyandNew安宇 In one place? And what kind of address? A memory address? A URL? A post address?
And what does semantically mean?
Hmm I know what functions do.
So we have variables, structures, objects, and arrays.
even more confused
 
@Cerberus sorry, I meant like a street address
it's made up of multiple parts
number, street name, street type, city, province, country, postal code
suite number
etc
those could all be member variables in an Address object
The program can then pass the object around atomically instead of as lots of little parts
so I can have a function like "sendMail" which takes two parameters, 1. an address, 2. a message to send.
or maybe the message is an object and I can tell the message "accept this address as your destination" and then I can tell it "now send yourself to that address"
But where object-oriented programming really gets useful is when you have polymorphism and inheritance.
inheritance is where you declare that a certain kind of object is a sub-type of a larger class. polymorphism is where the methods of the subtype automatically replace the methods of the super-type.
So I might have an object called "Animal" and a sub-type called "Cat" and another called "Dog". Each of them has a "feed" function which I can call even if I don't know if my variable is a cat or a dog or some other kind of animal.
That makes the code simpler (when done properly) because you can write small, elegant functions that can handle all the future cases you might encounter.
 
1:21 AM
@Mr.ShinyandNew安宇 Doesn't this sound a bit like an array? Related variables?
 
@Cerberus an array typically is all variables of the same type.
and they're ordered.
a structure is composed of variables of any type and they're labelled instead of ordered.
 
And objects can have different types?
 
OK.
And how are they labelled?
 
Cat is a different type from Dog.
But Cat is a subtype of Animal and so is Dog.
@Cerberus they have names in the code.
An array is indexed by number.
So you could say "item zero in the array is the street number, item 1 is the street name, item 2 is the street type, item 3 is the suite number..."
but that's clunky and fragile
 
1:24 AM
Hmm.
 
instead you have address.number, address.street_name, address.street_type, address.suite_number....
or whatever
 
I think I've seen that in Javascript.
 
using labels makes it easier to read, and means that you can change the order easily.
of course, you can fake all of this, depending on your programming language, but it's nice when the language has the features built-in.
 
Autohotkey has objects too.
@Mr.ShinyandNew安宇 Ah, OK. That makes sense.
> Types of objects include:

•Object - scriptable associative array.
 
ah, "associative array"....
I prefer to call that "map"
an associative array is a more generic concept than a regular array.
essentially it re-defines the normal traditional array to be a mapping of numbers to values
then it says "why just numbers?" and allows other key types
then your arrays are just maps
Traditional arrays are contiguous in computer memory
each item in the array is the same size
 
1:29 AM
> Array := {KeyA: ValueA, KeyB: ValueB, ..., KeyZ: ValueZ}
Array := Object("KeyA", ValueA, "KeyB", ValueB, ..., "KeyZ", ValueZ)
 
yeah I'd call those "maps"
 
This is how you can create associative arrays in Autohotkey.
 
that second syntax is yuck
 
Why?
 
just to make things funner, arrays can be stored (or referenced) in variables and also arrays contain variables, and also arrays can be objects (they are in Java and probably are in AHK but aren't in C)
@Cerberus because it offers no protection for getting something wrong. The first syntax uses punctuation to clearly indicate which are keys, which are values. The second relies on position.
If you make a mistake editing that code, you might end up with a bunch of keys stored as values and vice versa
I mean, I wrote code that worked like that, it was convenient for a use case, but it's ugly. The only reason I did it was because the first syntax wasn't available in Java.
 
1:36 AM
Hmm but I would suspect that only a string in quotation marks is accepted as a key, and vice versa?
 
@Cerberus I would expect that any string (literal or variable) would work as a key and anything would work as a value
 
Hmm.
 
but it's ahk... who knows.
 
I think they follow common conventions if there is no simpler way.
Especially later additions to Autohotkey seem to follow common conventions.
 
@Cerberus a well designed language picks a convention and sticks to it.
 
1:38 AM
Yes, it does so.
 
AHK seems to be a hodgepodge of conventions that have been glued together over time.
just, whatever was needed at the moment to get something done.
 
It may pick common convention A is there is no simpler way of doing what it does, but it may not follow convention B if it can think of a simpler way of doing what B does.
Mm sometimes, but it does have consistency in mind usually.
The one thing where it is lacking consistency in a bad way is when variables need to be enclosed in percentage signs and when they don't.
And the same for strings and quotation marks, mutatis mutandis.
 
yeah that's a fairly big problem
string handling is a major source of bugs and security issues
 
You just have to look it up in the documentation of the IDE.
 
you shouldn't have to for things like that though.
it's a warning sign.
 
1:43 AM
But I believe you don't always have to mark variables as such in other languages too, do you?
 
It's like if you wanted to say something in english, you knew all the words, but had to look up in a grammar book how to say it.
@Cerberus it varies.
 
That's why I mentioned it as a bad point.
@Mr.ShinyandNew安宇 Right.
So I might have the same problem in other languages?
 
Some languages require variables be marked with decorations
 
Oh, I remember now.
 
some languages don't.
 
1:44 AM
I had this horrible issue with quotation marks and variable signs in Python.
Using regex in Python was excruciating.
Autohotkey was far, far easier.
 
okay, so regexes are something that a lot of languages get wrong
the problem is that regex is a kind of language with its own syntax
 
@Mr.ShinyandNew安宇 But often the decorations are, within the same language, sometimes used, but not always, right?
 
@Cerberus I wouldn't say "often". Off the top of my head I can't think of a language that has optional decorations.
 
Not optional.
 
in PHP, for example, variables start with $
 
1:45 AM
But depending on the context.
> YoutubeTime := RegExReplace(Tempclip, "^.*(#t=[0-9]+s).*$", "$1")
A line from my Autohotkey script.
 
in Javascript, variables can start with almost any character. If you name your variable $blah, then that is its name and you will always refer to it as $blah
 
Both YoutubeTime and Tempclip are variables. I believe they wouldn't require decorations in Javascript in that situation, would they? But sometimes variables do require decorations in Javascript, don't they?
 
That's not a very complicated regex... the equivalent python code should be similar?
variables never require decorations in JS
it's not a thing there
you can use certain symbols in the variable names, but that's just making it part of the name
So in JS, var x; var $x; is legal; that's two different variables
 
Oh, okay.
 
s/.*(#t=[0-9]+s).*$/$1/
 
1:48 AM
How about in PHP? Do variables always, always use decorations?
> import re

eg.globals.filename = re.sub(r'\\\\', r'\\', str(eg.event.payload))
eg.globals.filename = re.sub(r'\\\\', r'\\', eg.globals.filename)
eg.globals.filename = re.sub(r'\\$', r'', eg.globals.filename)
eg.globals.filename = re.sub(r'^\(u\'', r'', eg.globals.filename)
eg.globals.filename = re.sub(r'\'\,\)$', r'', eg.globals.filename)
print eg.globals.filename
A regex thingy in Python.
 
sigils
 
It took me ages to come up with this horrible, ugly code.
Because I had to escape escape characters and whatnot.
 
@Cerberus I think so? But PHP is an abomination from Hell.
 
Haha.
I didn't know you liked PHP so much.
 
@Cerberus yeah so here's the thing: languages with C-style strings use backslashes to escape certain characters in the strings
but regexes use them the same way for the same reason for different escapes
 
1:50 AM
Yeah.
 
So when using a string to store a regex you need to escape the backslash
 
In Autohotkey, I can simply...change the escape character temporarily.
 
that'd be useful.
it complicates compilers slightly though.
 
@Mr.ShinyandNew安宇 $pattern = qr/this\b.*needs?\s+no\s+escapes?\b/
 
> #DerefChar # ; Change it from its normal default, which is %.
#Delimiter / ; Change it from its normal default, which is comma.
#EscapeChar \ ; Change it to be backslash instead of the default of accent (`).
 
1:52 AM
Similarly, in Go you can use backticked strings for this.
 
@tchrist right but you're not putting the regex in a string literal there.
 
Again, no need of fugly slack bashing.
@Mr.ShinyandNew安宇 I’m not?
 
Ultimately it is a problem of embedding one kind of language into another.
@tchrist no, that's a regex literal
 
Yeah.
 
I wouldn't consider those to be the same thing
 
1:53 AM
Yes, it is. You prefer perhaps the string version? 'this\b.*needs?\s+no\s+escapes?\b'
 
But it also wasn't clear to me where and how I had to put quotation marks in the Python regex command.
 
@tchrist which language is this?
 
You may have one guess.
 
@Cerberus probably because you're unused to how python does strings.
 
Probably.
But in Autohotkey it feels more consistent.
 
1:55 AM
@tchrist perl 5? So does perl5 have C-style string escapes? or does it have multiple string syntaxes?
 
And the documentation for Autohotkey is much, much better than anything I have ever found for Javascript or Python.
That also helps.
 
@Cerberus Did you ever come across the official python regex documentation? docs.python.org/2/howto/regex.html
 
Perl has "interpolated strings" where backslash blah counts, and 'uninterpolated strings' where for the most part it does not.
 
@tchrist ah, like python's "raw string" syntax where there are no backslashes
 
@Mr.ShinyandNew安宇 Possibly. But it's not Regex itself I found confusing.
I like Regex. It's clear and easy. Comparatively.
 
1:56 AM
haha "python" and "regex" and "documentation" all in the same sentence. haha haha
Perl is lot easier to use regexes in than Python is. But you knew that.
And rather better documented in that regard.
And you're welcome. :)
 
Hah.
I believe it.
 
Most languages are not bad at documenting how regexes work. Not awesome, but acceptable.
 
@tchrist Has it also been provided with ample example for every use case?
 
@Cerberus I will let you judge that for yourself.
 
1:58 AM
The python page at least warns you about the backslash problem... The Javadocs for regex do not.
 
It also took me some time to find out that, in Python, white spaces have meaning.
 
Java regex lib has a lot of suckage, but at least it tries.
 
I was indoctrinated such that white spaces are meaningless in computer languages.
 
@Cerberus Worst mistake ever.
 
@tchrist Or best thing ever, depending on who you ask
honestly though, it's not worse than any decision the PHP devs ever made.
 
1:59 AM
@Mr.ShinyandNew安宇 I even had to import a special library to get Regex working in Pythin in the first place. I'm so spoiled with Autohotkey.
 
@Mr.ShinyandNew安宇 I didn't know there were PHP devs.
 

« first day (2072 days earlier)      last day (2852 days later) »