Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

Cuntpunch posted:

It's been a little bit since I've touched WPF.

Just to understand the hierarchy:
code:
ParentControl
-DataContext
-ChildControl
--DataContext
--ContextMenu
If so, doesn't the ChildControl inherently have a dependency on whatever out of the parent DataContext and needs that provided in a property, so that it in turn can provide it to the ContextMenu? Which is to say: Doesn't ChildControl get everything it needs to function out of the ParentControl's DataContext?

For most things you can use a trick in XAML where you refer to the datacontext of an ancestor element in the visual tree. For context menus this doesn't work, because they "are not part of the visual tree" and so don't fit into the hierarchy (even if the XAML that defines the context menu appears in a definite position in the hierarchy so that it could in principle be figured out)

I just made the child control have a reference to an object that can communicate with the parent, because that's simpler than figuring out how to do it in XAML. Of course, then the parent has to be able to inform its children when the relevant property changes, otherwise it's not updated in the UI, so that means putting a load of obnoxious extra method calls in the parent viewmodel...

It would help if the code that creates the child object hadn't been written by a lunatic. Say, if you have two classes A and B, what is a good name for an instance of class A? Well it's "b", of course.

Rant over, apologies

Adbot
ADBOT LOVES YOU

moostaffa
Apr 2, 2008

People always ask me about Toad, It's fantastic. Let me tell you about Toad. I do very well with Toad. I love Toad. No one loves Toad more than me, BELIEVE ME. Toad loves me. I have the best Toad.
This probably belongs here: https://www.zdnet.com/article/yelp-for-conservatives-maga-app-leaks-users-data/

quote:

But according to Robert Baptise, a French security researcher who goes online under the pseudonym of Elliot Anderson (the name of the main character from the Mr. Robot TV show about hackers), the 63Red Safe app is leaking almost all of its data.

Baptise says the app's source code contains the credentials of its author, but also a list of API endpoints to which it connects to store or retrieve data.

This backend API doesn't use any form of authentication, Baptise said. This means that anyone can look at the app's source code, get the API endpoints, and then extract data from the app's server with no challenge or restriction.

Using this technique, the French researcher was able to determine that 4,466 users had registered and created profiles since the app's launch over the weekend.

For each profile, Baptise said he was able to retrieve information such as username, email, avatar, follower count, following count, profile creation/update dates, a ban status, and something called a "hotscore."


https://twitter.com/fs0c131y/status/1105259901205516288

Drastic Actions
Apr 7, 2009

FUCK YOU!
GET PUMPED!
Nap Ghost

It’s React Native, and the dev put the auth keys in the JavaScript side, so it got bundled in the APK as a string. So the steps the security researcher took was:

Downloaded APK from Mirror site
Unzip
Open app bundle
Ctrl-F “password”

And they knew how to POST requests

It’s a known thing with React Native that it does this, but I can totally see people being bit by it if they don’t understand what it’s doing, and how they should better protect their keys.

Hopefully now more people can get articles in ZDNet with the advance hacking techniques I’ve provided.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

ultrafilter posted:

Trying to understand the inner workings of anything Microsoft made in the 90s is a bad idea.

some microsoft apis are some obtuse that i seriously believe that the company was partially staffed by extra-terrestrials or schizophrenics, especially once you start getting into the finer details of COM or the ATL.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Bruegels Fuckbooks posted:

Just do windows key + R, calc, and watch how long it takes the window to show onscreen. Compare it with say, windows + R, notepad. Notepad shows up nearly instantly imperceptibly fast, I'd estimate calc shows up in about 400 ms on my windows 10 laptop with an SSD just eyeballing it.

And on mine it's up before the run window is done fading out :shrug:

raminasi
Jan 25, 2005

a last drink with no ice

Bruegels Fuckbooks posted:

some microsoft apis are some obtuse that i seriously believe that the company was partially staffed by extra-terrestrials or schizophrenics, especially once you start getting into the finer details of COM or the ATL.

hackbunny's deep dives into Windows internals in YOSPOS have been described as "like reading an alien autopsy."

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

raminasi posted:

hackbunny's deep dives into Windows internals in YOSPOS have been described as "like reading an alien autopsy."

Seriously I can't understand 10% of what they post in there.

Achmed Jones
Oct 16, 2004



But they should never stop, because it rules

Jewel
May 2, 2009

Where can I find these?

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Jewel posted:

Where can I find these?

I think mostly in the programming languages thread.

QuarkJets
Sep 8, 2008


Thank goodness that I can find safe spaces where I can go and complain about liberals and their safe spaces

oh gently caress there go the common credentials that I use for everything, username CoolDude69 password TrumpR0x!

hackbunny
Jul 22, 2007

I haven't been on SA for years but the person who gave me my previous av as a joke felt guilty for doing so and decided to get me a non-shitty av
TIL: in C/C++, the braces in the switch statement are optional if you have a single case

C++ code:
int main(int argc, char **argv) {
    switch (argc) case 1: return 1;
}
:pwn:

Thermopyle posted:

I think mostly in the programming languages thread.

I once made a dedicated thread too

hackbunny fucked around with this message at 09:20 on Mar 13, 2019

Mooey Cow
Jan 27, 2018

by Jeffrey of YOSPOS
Pillbug

hackbunny posted:

TIL: in C/C++, the braces in the switch statement are optional if you have a single case
:pwn:
You can in fact have any number of cases, as long as there is only one statement.
https://en.cppreference.com/w/cpp/language/switch


The grammar that makes this possible is also what makes else-ifs possible btw. Most people probably think there are special syntax rules for that, but the grammar is actually
code:
if-statement := if (expression) <statement>
if-else-statement := if (expression) <statement> else <statement>
where <statement> can be any statement, like a single expression, or another if, or if-else, or a while. You don't often see the else-while but you can write one. Things in curly braces are compound statements, and treated as a type of statement in the syntax.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

Mooey Cow posted:

You can in fact have any number of cases, as long as there is only one statement.
https://en.cppreference.com/w/cpp/language/switch


The grammar that makes this possible is also what makes else-ifs possible btw. Most people probably think there are special syntax rules for that, but the grammar is actually
code:
if-statement := if (expression) <statement>
if-else-statement := if (expression) <statement> else <statement>
where <statement> can be any statement, like a single expression, or another if, or if-else, or a while. You don't often see the else-while but you can write one. Things in curly braces are compound statements, and treated as a type of statement in the syntax.

Does that mean this is legal

code:
if (fart)
    butt();
else boners:
    rear end();

Xarn
Jun 26, 2015
The way variables in switches shadow is the worst. :colbert:

Mooey Cow
Jan 27, 2018

by Jeffrey of YOSPOS
Pillbug

Hammerite posted:

Does that mean this is legal

code:
if (fart)
    butt();
else boners:
    rear end();

That is legal; a label actually labels the statement following it, rather than being a statement in itself, so it's equivalent to
code:
boners: rear end();
although usually you'd put the label on a separate line so you could find easily it when going through your atrocious goto-ridden code :colbert:

Linear Zoetrope
Nov 28, 2011

A hero must cook

Mooey Cow posted:

You can in fact have any number of cases, as long as there is only one statement.
https://en.cppreference.com/w/cpp/language/switch


The grammar that makes this possible is also what makes else-ifs possible btw. Most people probably think there are special syntax rules for that, but the grammar is actually
code:
if-statement := if (expression) <statement>
if-else-statement := if (expression) <statement> else <statement>
where <statement> can be any statement, like a single expression, or another if, or if-else, or a while. You don't often see the else-while but you can write one. Things in curly braces are compound statements, and treated as a type of statement in the syntax.

Wait, what kind of grammar does C++ use? I remember when I took compilers we used an LR parser (flex/bison) and this definition of if/else if created a parsing ambiguity.

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆
IIRC C++ has so many syntax ambiguities that in mathematical terms the language is "undecidable".

One simple example:

code:
foo bar(baz);
Am I declaring a function bar that accepts an arg of type baz and returns type foo?
Or am I instantiating a foo object named bar, passing a variable named baz to the constructor?

The only possible way to know is to look at the context around the statement.

Xarn
Jun 26, 2015
The first, because the language spec says so :v:

Xerophyte
Mar 17, 2008

This space intentionally left blank

Linear Zoetrope posted:

Wait, what kind of grammar does C++ use? I remember when I took compilers we used an LR parser (flex/bison) and this definition of if/else if created a parsing ambiguity.

The C language spec says that "an else is associated with the lexically nearest preceding if that is allowed by the syntax", i.e. prefer shift for the dangling else conflict. The C11 standard's final draft includes a grammar in Annex A and that grammar is indeed ambiguous when it comes to dangling else:

code:
(6.8.4)
selection-statement:
    if ( expression ) statement
    if ( expression ) statement else statement
    switch ( expression ) statement
As an implementer you can use whatever grammar you want, or none at all, as long as you implement the language correctly. If you're using an LR parser generator then I think they nearly universally resolve shift/reduce conflicts by favoring shift so it's a pretty common ambiguity that no one really minds. The reference Yacc grammar for C says

quote:

Note: There are two shift/reduce conflicts, correctly resolved by default:
IF '(' expression ')' statement _ ELSE statement
and
ATOMIC _ '(' type_name ')'
where "_" has been used to flag the points of ambiguity.
for instance. I work with a C-like DSL that has the same ambiguity in our flex grammar, resolved in the same way.

Xerophyte fucked around with this message at 21:17 on Mar 13, 2019

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?

RPATDO_LAMD posted:

IIRC C++ has so many syntax ambiguities that in mathematical terms the language is "undecidable".

One simple example:

code:
foo bar(baz);
Am I declaring a function bar that accepts an arg of type baz and returns type foo?
Or am I instantiating a foo object named bar, passing a variable named baz to the constructor?

The only possible way to know is to look at the context around the statement.

Another fun one: https://yosefk.com/c++fqa/web-vs-c++.html#misfeature-3

Mooey Cow
Jan 27, 2018

by Jeffrey of YOSPOS
Pillbug

Linear Zoetrope posted:

Wait, what kind of grammar does C++ use? I remember when I took compilers we used an LR parser (flex/bison) and this definition of if/else if created a parsing ambiguity.

There are indeed many ambiguities in the language, as it doesn't define any particular grammar, just a lot of syntax rules the compiler must follow. You may be able to use a GLR parser more easily though. GCC however switched from Yacc to a handwritten recursive descent parser many years ago. Clang has always used recursive descent I believe.


edit: There is however a grammar summary in appendix A:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3092.pdf#appendix.A

Mooey Cow fucked around with this message at 23:36 on Mar 13, 2019

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


RPATDO_LAMD posted:

IIRC C++ has so many syntax ambiguities that in mathematical terms the language is "undecidable".

I think C++ is decidable but hard to parse if you disallow templates. The problem is that templates are Turing complete, and that means that determining whether a given program is valid can require you to solve the halting problem.

Dr Monkeysee
Oct 11, 2002

just a fox like a hundred thousand others
Nap Ghost
Isn’t that the definition of undecideable?

I think strictly speaking the syntax is not undecideable but the semantics are, I guess it depends on which side of that you consider “parsing” to fall.

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?
I don't think templates being turing complete affects the parsing. Many turing complete languages are parseable after all. The issue (I believe) is there are ambiguities that can only be resolved if you know what kinds of things the tokens involved are (such as types or variables), eg:
code:
a < b > c;
or
code:
T *p;

Jeb Bush 2012
Apr 4, 2007

A mathematician, like a painter or poet, is a maker of patterns. If his patterns are more permanent than theirs, it is because they are made with ideas.

HappyHippo posted:

I don't think templates being turing complete affects the parsing. Many turing complete languages are parseable after all.

I think you're confusing a programming language being Turing complete (any Turing machine can be simulated by running a program written in the language) and the parsing of the language being Turing complete (you can take any Turing machine and any input to that machine, encode it in that language's source code, and the result of parsing said source code will be the output of the Turing machine on the specified input). The former is consistent with the language being parseable, the second means it is impossible to write a parser that will always successfully parse the language on all inputs, even if you have infinite space and time.

Jeb Bush 2012 fucked around with this message at 17:15 on Mar 16, 2019

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?

Jeb Bush 2012 posted:

You're confusing a programming language being Turing complete (any Turing machine can be simulated by running a program written in the language) and the parsing of the language being Turing complete (you can take any Turing machine and any input to that machine, encode it in that language's source code, and the result of parsing said source code will be the output of the Turing machine on the specified input). The former is consistent with the language being parseable, the second means it is impossible to write a parser that will always successfully parse the language on all inputs, even if you have infinite space and time.

But does the "turing complete" nature of templates come in during the parsing step of compilation, or later? (I'm genuinely curious)

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


It's not that templates allow you to perform arbitrary computations; it's that they allow you to perform arbitrary computations *at compile time*. At some point someone implemented a piece of code that took an int n and produced error messages listing out all of the primes less than n, but I'm having trouble tracking that down.

ultrafilter fucked around with this message at 17:35 on Mar 16, 2019

Volte
Oct 4, 2004

woosh woosh
The only way the parsing could be Turing complete is if you could arbitrarily extend the syntax or modify the source code at parse-time. Otherwise as long as you are consuming a static finite-length string, it's either going to terminate or enter an infinite loop with no progress being made.

PederP
Nov 20, 2009

Anyone who is confused at how c++ templates can be Turing-complete and are thus subject to the halting problem, should look up std::conditional. Essentially the compilation of templates can be considered executing (ie evaluating) a functional program.

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?

ultrafilter posted:

It's not that templates allow you to perform arbitrary computations; it's that they allow you to perform arbitrary computations *at compile time*. At some point someone implemented a piece of code that took an int n and produced error messages listing out all of the primes less than n, but I'm having trouble tracking that down.

Yes but there are multiple steps involved in compilation. Parsing is just one step. The question is, is the parsing undecidable due to the turing complete nature of templates, or some other reason?

Jeb Bush 2012
Apr 4, 2007

A mathematician, like a painter or poet, is a maker of patterns. If his patterns are more permanent than theirs, it is because they are made with ideas.

HappyHippo posted:

But does the "turing complete" nature of templates come in during the parsing step of compilation, or later? (I'm genuinely curious)
With the caveat that the clean lexer->parser->code generation abstraction isn't (afaik, I'm not a compilers person) exactly how real compilers for C-family languages work, yes.

Volte posted:

The only way the parsing could be Turing complete is if you could arbitrarily extend the syntax or modify the source code at parse-time. Otherwise as long as you are consuming a static finite-length string, it's either going to terminate or enter an infinite loop with no progress being made.

This is wrong because the parser is allowed to (and must!) maintain its own state to help in parsing. One thing you're allowed to do at parse time is check whether you've got a valid program, for instance, which means deciding any set, including undecidable ones, can be cast as a parsing problem.

I think you're maybe getting hung up on the fact that the output is not arbitrarily large, but, for one thing, it is (because, as ultrafilter pointed out, parsers can output error messages) (e: and, as pointed out below, even your non-erroneous output can be arbitrarily large), and even if it wasn't that wouldn't really matter (if you have a machine that can simulate any function with a 1-bit output, you can simulate any function with an arbitrarily long output by running it multiple times on a modified 1-bit output function).

Jeb Bush 2012 fucked around with this message at 18:02 on Mar 16, 2019

Xerophyte
Mar 17, 2008

This space intentionally left blank

Volte posted:

The only way the parsing could be Turing complete is if you could arbitrarily extend the syntax or modify the source code at parse-time. Otherwise as long as you are consuming a static finite-length string, it's either going to terminate or enter an infinite loop with no progress being made.

Parsing C++ may require arbitrary template instantiation, and is not simply consuming a static finite-length string. Since template instantiation is undecidable, so is parsing. Instigating example.

This has little practical impact: people don't write undecidable template instantiations and C++ compilers do not in fact allow arbitrary template instantiation no matter what the language spec says.

Volte
Oct 4, 2004

woosh woosh
Jesus, I didn't know that template instantiation happens during parsing. That is absolutely bizarre behaviour.

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


Volte posted:

Jesus, I didn't know that template instantiation happens during parsing. That is absolutely bizarre behaviour.

That's why the body of a template function has to be visible everywhere that it's called, and why templates are a very bad idea if you care about binary size.

Volte
Oct 4, 2004

woosh woosh

ultrafilter posted:

That's why the body of a template function has to be visible everywhere that it's called, and why templates are a very bad idea if you care about binary size.
That would still be true if templates could be unambiguously parsed into AST nodes prior to instantiation, though. My mistaken belief was that a template could be parsed into an AST node with holes for the arguments, which could then be instantiated later in the compilation process. In other words, when I type vector<int>, it would be turned into an AST node like TemplateInstantiation(Symbol("vector"), Symbol("int")) and it would move on to the next token, even if the instantiation of that template itself was a Turing machine. If this were the case, then the parsing step would be trivially decidable, but you'd still need to have access to the AST of the template at the instantiation site. Of course I forgot about the ambiguity of pointer and function syntax though.

I guess it basically comes down to the fact that parsing isn't really its own phase when it comes to C++.

Volte fucked around with this message at 18:31 on Mar 16, 2019

Xarn
Jun 26, 2015
I am just gonna leave this type-level TM implementation here
http://coliru.stacked-crooked.com/a/de06f2f63f905b7e

Bonfire Lit
Jul 9, 2008

If you're one of the sinners who caused this please unfriend me now.

Xerophyte posted:

This has little practical impact: people don't write undecidable template instantiations and C++ compilers do not in fact allow arbitrary template instantiation no matter what the language spec says.

Even the spec says that there's a limit on the number of recursively nested template instantiations (the exact limit is implementation-defined, but recommended to be at least 1024).

Bonfire Lit fucked around with this message at 19:50 on Mar 16, 2019

Mooey Cow
Jan 27, 2018

by Jeffrey of YOSPOS
Pillbug

ultrafilter posted:

templates are a very bad idea if you care about binary size.

Not really. Maybe 20 years ago, but if you need code to work over multiple types, they generally result in identical code to handwritten specializations. Sometimes smaller, since unused template functions and methods are not even emitted (although unused handwritten code could also be removed at linktime). It's also usually possible to separate out code that doesn't depend on the type to avoid unnecessary code duplication within functions, but you would also have to do that if you wrote your functions by hand and wanted to minimize size.

Adbot
ADBOT LOVES YOU

SupSuper
Apr 8, 2009

At the Heart of the city is an Alien horror, so vile and so powerful that not even death can claim it.
They still suck for compile time though.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply