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

02:00
@Cerberus Yeah, reges are second-class citizens there.
@tchrist well, "devs" then.
@tchrist Well, I didn't make a mistake so much as I just couldn't find how if thingies worked.
@Cerberus It's not uncommon to have to declare which modules you want to use.
But how was I to know, when I saw a Python Regex example and somehow it didn't work for me?
It allows for evolution of the libraries. You could have two modules that provide the same functions
02:01
Autohotkey has libraries.
But it includes things like Regex.
@Mr.ShinyandNew安宇 Regexes aren't first class citizens in the language, which produces inefficiencies and surprises.
@tchrist Or did you mean it was a mistake of Python's?
@Cerberus Yes.
To use tabs to mark off if thingies.
OK.
I meant it was a mistake of Python's, not of yours.
02:02
phew
@Cerberus You don't need to use tabs. You just need to use consistent spacing.
Consistent?
The space bar works too?
I see.
It does.
It still bites.
02:04
Another thing I like about Autohotkey is that capitalisation doesn't matter.
That's a bug to most of us.
But it wouldn't bother you.
My understanding is that you can indent with any number of spaces or tabs, as long as each line is indented the same as above, or, if a new block is required, indented more, or if a block is ended, indented the same as the previous block.
It would bother me.
@Cerberus That would bother me.
02:05
Surely you wouldn't want to be using Var and var at the same time? It would be confusing.
Several languages use capital letters to denote classes and lower case to denote variables.
So I can say Cat cat = new Cat();
Cat is the type. cat is the variable.
Genus species.
You can still do that using the appropriate Autohotkey syntax?
How would I find that in the Autohotkey docs? "Class"?
@Cerberus possibly
@Cerberus The online Perl regex docs are really quite extensive, and that isn't even talking about the guts, just the user-level stuff. Plus the Camel's regex chapter is more than 100 pages long, which is followed by a 40-page Unicode chapter that is tightly coupled in many places to regexes.
02:07
> class ClassName extends BaseClassName
{
InstanceVar := Expression
static ClassVar := Expression

class NestedClass
{
...
}

Method()
{
...
}

Property[] ; Brackets are optional
{
get {
return ...
}
set {
return ... := value
}
}
}
Example code from the doc.
Bad indentation.
@tchrist Great!
@tchrist It is properly indented in the doc.
Does this look inconvenient or confusing to you?
Just curious.
I disapprove of the use of :=
Why?
But that's unrelated to capitalisation.
You can also use just = in Autohotkey.
because value assignment is a constantly done thing and I hate typing needless crap
02:11
In computer science and information theory, a Huffman code is a particular type of optimal prefix code that is commonly used for lossless data compression. The process of finding and/or using such a code proceeds by means of Huffman coding, an algorithm developed by David A. Huffman while he was a Ph.D. student at MIT, and published in the 1952 paper "A Method for the Construction of Minimum-Redundancy Codes". The output from Huffman's algorithm can be viewed as a variable-length code table for encoding a source symbol (such as a character in a file). The algorithm derives this table from t...
Because you type assignment a bazinga times more often than you do equality tests.
So it makes sense for the more common operation to be shorter.
You can use either = or :=
> The latter method is preferred by many due to its greater clarity, and because it supports an expression syntax nearly identical to that in many other languages.
@Cerberus identical to many other languages, each of which I hate
I use Huffman optimization on my identifier names. Stuff I don't want people to use I make hard to type. :)
Haha.
Well, then you can use the = method.
@Cerberus See, that, to me, is a warning that the language is poorly designed.
02:14
It is designed with convenience in mind.
Oftentimes, different people want different methods.
@Mr.ShinyandNew安宇 Were you also damaged by a Pascal or Modula or for the love of all that's holy Ada compiler as a small child?
yuck
I turned down a better-paying job because it would be all PL/SQL all the time.
@Sᴋᴜʟʟᴘᴇᴛʀᴏʟ thankfully no.
Well of course you did. My mother wouldn't even put up with it.
Anyway, does the class thingy shown in the example look inconvenient to you, just because it doesn't depend on capitalisation?
"Depend on capitalization"?
@Cerberus Well, not really, except that then I can't do the Cat cat = new Cat(); thing, and also it encourages people to write stuff with no capitals.
02:17
CONSTANT_SYMBOLS Global_Variables local_ones
I don't really understand what your catty thing does, but doesn't Autohotkey provide for a way to do that in the example?
That's what capitalization means to me. Violate that and I won't touch your code.
Oh, I see.
@tchrist granted you can still do that in case-insensitive languages, but when I write a module that calls your constant_symbols and the compiler allows it.....
I use capitalization meaningfully.
02:19
@Cerberus Sure, I can still write the same program, but I can no longer use Cat and cat as two different symbols
I'd have to write something like Cat aCat = new Cat();
because even though the capitalization means something to me, it doesn't to the compiler.
And yet if ($if > @if) { &if } is not something that will endear you to most people.
@tchrist Sure, it can be abused.
In Java you can have a method with the same name as a constructor.
it's a good way to get beat up after work.
@Mr.ShinyandNew安宇 Okay, so that doesn't look terribly inconvenient? Or is it?
In Autohotkey, variables are global by default.
@Cerberus that's a bug
In function definitions, they're local by default.
02:22
That's a bug.
How so?
variables should be local to the nearest enclosing scope
Scope should not be context sensitive.
Isn't a function definition a scope?
We're probably talking about the same thing.
I guess AHK is a little like a bash script
02:23
The scope of a variable should not change depending on whether you use it in a function or not.
if you declare your variables at the start of your script, they're global to the script
If I write a function like this:
@tchrist I think he's referring to where it's declared
Hm.
I'm not sure he declares things. It might be like shell scripts.
> function() {
teststring = blah
}
02:24
oh right.
Then teststring will be local to the function.
that kind of variable declaration.
that entire paradigm is a bug.
That's not really declaration.
variables should have to be declared.
Right.
02:25
Ah, but that would be very inconvenient.
What if there were a variable in a surrounding scope called teststring?
@Cerberus Are you sure you don't know FORTRAN? :)
@tchrist I don't know.
@Cerberus It saves you from a world of pain if your code is ever changed after the first time you use it.
How so?
It's so important to good coding practices that Javascript added the ability to require that variables be declared before use.
@Cerberus well, let's say you have a function with a variable blah.
02:26
> The IMPLICIT NONE statement is used to inhibit a very old feature of Fortran that by default treats all variables that start with the letters i, j, k, l, m and n as integers and all other variables as real arguments. Implicit None should always be used. It prevents potential confusion in variable types, and makes detection of typographic errors easier.
Then tomorrow you are editing your code and you add a blah to the global scope.
The next time you use your function, instead of referring to a local variable, it refers to a global one.
Or a teststring to the global scope.
You now have to know everything about everything that hasn't happened yet.
> if a function parameter or local variable with the same name is declared, it takes precedence over the global variable.
Also, the day after tomorrow you edit your code and refer to the variable blsh
You didn't notice the typo but the interpreter just blithely allocates a new variable.
The write to blah never happens because it was written to blsh
weepin beebee jeebitz
And this is one of the reasons I refuse to touch python.
Much worse than the white space thing.
There is no strict mode.
I prefer for the compiler to tell me about screwups like that.
02:29
@Mr.ShinyandNew安宇 Well, the code fails either way, then, doesn't it?
Hope it isn't a life-support control on a spacecraft.
If we fail, we fall. —Gandalf
@Cerberus but if you were required to declare variables, then the bugs I mentioned wouldn't have happened.
At any rate, I don't get how having to declare variables would solve the problem of inadvertently using the same variable name for two things that should be different. You have a problem either way, don't you?
No, you don't.
Because they remain different then.
Why?
02:31
Because you declared their scope.
In the case where a function variable got turned to a global, that wouldn't happen because the variable declaration in the function would create a new variable that obscures the first one. In the second case you'd get an error at compile time (or run time) about an undeclared variable
int x = 10;
if (rand() > 0.5) {
    int x = 20;
    print(x);
}
print(x);
Those are two completely different variables.
@Cerberus In some languages it would be a compiler error. In most languages it just means that in the function you can't see the global x because there is a local x.
I'm not sure I understand that.
Actually I'm not sure if there are languages where you can't create a local x that hides a global x.
02:33
The if block is free to use variables of whatever name it pleases, and cannot be broken if somebody later adds another variable of the same name above or below it.
@Cerberus when looking for a variable, the compiler looks in the current scope, then the parent, then the parent, and so on.
it takes the first one it finds.
@Mr.ShinyandNew安宇 javascript's scope is broken
@tchrist And they would be different too in Autohotkey, apparently.
@Cerberus They are not different in AHK
I thought the second x was local?
02:34
I'm not sure what "local" means here. :)
It is visible only within its block.
Or maybe an if block doesn't have local things in Autohotkey. I don't know.
I used an if block because it was easier to type.
can you do this in AHK:
x = 10
function p() {
print(x);
}
I could have used a function as well.
@Mr.ShinyandNew安宇 Yes: if there is no overlap, the function will see the global.
02:36
@Cerberus right.
So let's say you have a function:
function p() {
    x = 2
    print(x)
}
says it
and then later on, someone adds an x to the global scope with a value of "Cerberus"
then calls p()
Ohh.
Now some clown comes by and ruins your life.
I like being inside a variable.
But I see the problem.
02:37
You're a value, not a variable
The variable is x
This is true.
He's an rvalue not an lvalue.
The problem is that the clown could show up a lot later than you think.
So but a similar problem would happen if someone added an x to the global scope twice, wouldn't it?
So if variable declaration is required, p() must declare a new name called x. Later, when someone modifies the global scope to add an x, it doesn't hurt p() because p() already defines its own x. p() can't see the global x but that's fine.
What compiler would not complain if it were at the same scope?
@Cerberus yes, and similarly, requiring declaration prevents that.
@tchrist AHK or python or javascript in non-strict mode won't complain, because there is no declaration to complain about.
02:40
@Mr.ShinyandNew安宇 I hate pos code.
@Mr.ShinyandNew安宇 But it's not fine if p can't see the global x, if the person who added the global x somehow counted on p's seeing x?
The crucial thing here is that knowledge is limited by scope, and therefore you are safe.
So how does declaration work, and how does it prevent people from using the same name for different variables by accident?
You can write a function that is completely safe.
I wouldn't even know how to declare a variable.
02:41
A duplicate declaration is usually a compiler error, if it is at the same scope.
But I have some work to do before bed, and it's already 4.40.
Well, you need a keyword to declare it.
I have to go too.
@tchrist Hmm I see.
@Cerberus No, if a person adds a new variable "x" to a global scope, they should logically expect that nobody uses it, and anyone they want to use it needs to be modified.
int x;
float num;
char *crap[32];
02:43
@Mr.ShinyandNew安宇 Hmm.
By modified you mean notified?
@Cerberus No. I mean, if I take one of your scripts, and add a variable called cat, why should I expect that any function in your script uses that variable?
This is why Mrs Clinton wants every student to take some programming class(es) before college.
I have to inspect that script and modify every function that I intend to use my cat
@Mr.ShinyandNew安宇 Yes, I understood that.
@Mr.ShinyandNew安宇 Ah OK.
Then "anyone" is a typo?
@Cerberus I meant it as "any function"
sorry, personification, it's a thing programmers do
02:45
Ahh OK.
I think I see the advantage.
But I also see a disadvantage: it requires much more coding, doesn't ?
If you forget to declare the function, or if you delete the declaration by accident, or if the code that is supposed to declare it isn't executed for some reason, you have a problem.
Not really.
Because if declarations are mandatory, if you delete the declaration, you no longer have a program.
That is, the compiler will reject it.
Oh, I see.
So much depends on the compiler...
@Cerberus normally it's not an issue because you are used to doing it. and its benefits outweigh the costs.
That's its job.
But what if the declaration is there, but it isn't executed when it should?
02:49
I don't understand.
Actually, strike that.
I don't want to type := in assignment, but I do want the compiler to force me to type var in front of variable declarations in Javascript.
E.g. you call a variable before it is declared.
You don't understand that declarations are not executable statements.
@Cerberus That's not legal.
@Mr.ShinyandNew安宇 Yes, so you'd have a problem, no?
02:50
Therefore, there is no possibility that it would not be executed. Or would be. It cannot execute.
@Cerberus well, yes, the same as if you didn't put in the declaration, because it's the same error.
You cannot use a variable before it is declared. That's why you have to declare it. The compiler is a stern mistress.
But would the compiler know?
Oh yes.
The compiler knows everything. :)
I wonder if there are compilers that hoist variable declarations that allow using before declaring....
02:52
I prefer not to wonder about that. :/
But the declaration might be in a function at the top of the script, and I might call it in another function at the bottom. And I have marked the variable as global in both scripts because I will want to use it later again.
How would the compiler know?
@tchrist ah, yes, Typescript does that
@Cerberus I don't follow, sorry.
I'd love to have such a smart compiler.
5
Q: Why does typescript allow variable to be used before declaring it?

AmitabhTypescript does not give a compiler error for the following code: var b = a + 10; // Why no compilation error here var a = 10; alert(b.toString()); I would expect the first line to be an error as I have not declared or initialized var a till this time. If I remove the second line I get the ...

02:53
In C, variables are int by default, but we will hate you.
Plus eventually the linker will have its way with you if it's in the global namespace.
@Cerberus The declaration has to be in the scope it's in.
Ok, I think I may see what he's getting at.
There is declaration versus initialization.
> Function1() { I hereby declare global variable x }
Function2() { I hereby call upon global variable x}
I execute thee, function 2()
I multiply thee by three, o global variable x
Declaration is a compile-time thing, initialization a run-time thing, and it is possible to declare, then use, then init, and be in trouble.
@Cerberus In most languages that I know of you can't declare a global variable anywhere but in the global namespace.
02:56
You are conflating declaration with initialization.
Declaring a variable makes it visible, but initializing it gives it a value.
[ SmokeDetector ] Manually reported answer (batch report: post 1 out of 2): Where to buy cheap NFL jerseys? by wyadmin on english.stackexchange.com
Visibility is different.
Oh fine.
@Mr.ShinyandNew安宇 But that can be useful. I can do that in Autohotkey. I'd hate to have to work around that?
[ SmokeDetector ] Manually reported question (batch report: post 2 out of 2): Where to buy cheap NFL jerseys? by lrhwy on english.stackexchange.com
DO THE RIGHT THING
02:57
@Cerberus It can be useful, but there are ways to make that possible without throwing out variable declaration
You just have a global object where you can add stuff.
Spam flag both, all ye lurkers in the murk.
@SmokeDetector Flagged.
@Mr.ShinyandNew安宇 Sounds more complicated...
It's another of those spam seeds et semini ejus.
Dative?
@Cerberus Well, if you explain what you really want, we can tell you how it is normally used.
@Cerberus By their seeds? :)
02:58
@Cerberus Nah it's simple.
in the global scope you define a map (or "associative array")
in functions you can read/write whatever you want in it
@tchrist By would be an ablative. Dative is for indirect objects only, to/for.
And semini is dative singular.
@Cerberus The quote was promised something to your seeds.
Yes, to.
It was just a flash memory.
@Mr.ShinyandNew安宇 I wouldn't know how to do that. And, even if I did, it would require a lot of code.

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