josdejong / mathjs

An extensive math library for JavaScript and Node.js
https://mathjs.org
Apache License 2.0
14.31k stars 1.24k forks source link

Qml and Lint warnings and errors, at least one causing error in Qml. #1469

Closed Light-Wizzard closed 5 years ago

Light-Wizzard commented 5 years ago

I want to use this project in Qml JavaScript, I get many warnings and errors, I would like to address the ones that can and should be fixed, if for no other reason to get rid of warnings, as long as there is no unwanted consequences.

Qml JavaScript Engine is not the same as Web Browser JavaScript Engines, it does not require the use of "use strict";, because it is the default behavior, but this is more than a warning, it crashes.

In the example code below, the use of:

"use strict";

Crashes the loading of this code, I get this error on import:

MathJs.js:11050: TypeError: Type error

That line is:

ArgumentsError.prototype.constructor = Error;

if I replace

"use strict";

with

;"use strict";

It will run, thanks to MikeMcl for figuring this out, but on further investiation I wound that changing it to:

'use strict';

Note the single quote, the first error goes away, the library loads, but I still get an error message, even though the program runs, and returns the correct answer, now changing that to:

;'use strict';

Gets rid of all error messages.

Do you want me to limit this thread to one issue, and change the title to use strict, closing each ticket one at a time, or just list each warning, and work on all of them in this ticket, one at a time, considering that most warnings are just normal Lint warnings, for example, Qml gives errors if you use new before a lower case function, causing you to change to a Capital letter if you want to use new, and lower case if you do not, and it does not like the use of == over ===, and it does not like the syntax like:

var algorithm14 = function algorithm14(a, b, callback, inverse) {

it wants:

var algorithm14 = function (a, b, callback, inverse) {

This is just a sample of what I want to address, and doing do in this tread works for me, but does it work for you?

I tested this change on my code in a Web Browser and it works, so the change from:

"use strict";

to

;'use strict';

Will not cause any issues for any JavaScript Engine I tested, but it needs to be tested on more Engines than I have access to, considering I only tested this on Linux.

Thanks

josdejong commented 5 years ago

Related issue: #1454

Thanks for summarizing these Qml issues @Light-Wizzard.

It is out of scope to address these issues in mathjs itself, and have mathjs itself stay compatible with the quirks of the Qml JavaScript engine. We focus on keeping mathjs ES5 compliant, and hope all JavaScript engines will do there best for that too.

I think the best is to create a separate project which ports math.js to Qml. Or maybe it's enough to have a script which takes the math.js bundle as input, and outputs a Qml compatible version. So this script would remove the "use script"; occurrences and change named function expressions, and there could be more issues like these now or in the future. Maybe the script could even get other libraries than mathjs working for Qml too :).

Light-Wizzard commented 5 years ago

I like that idea, and agree, how about a compromise, maintain one bash script can call it something like web2qml.sh, it can be community maintained, running it will take the latest version you have, and replace all warnings and errors with code that fixes these issues the way the Qml Engines want, so it is using grep and sed to do all the work, this file output could also be used to make a file called something like mathqml.js, and this is only maintained via the script that makes, so the two projects do no drift apart, if you agree with this, I will write and maintain the bash script, which is community driven after that, so on your part, would require 3 files total, the bash script, the output, and a read.me file to explain this project and how to report bugs for it, if you wanted to provide Qml Examples, I can provide a Calculator example for Qt Qml as well as Felgo, if you do this, you will get more support from those communities, the read.me file should explain that this is only a community driven project, and state that all support is community driven, as to not impose any more maintenance on your end, other than adding the files, and updating them.

I agree that all JavaScript Engines should work the same, and we can all agree they do not, so this project can also be used to fix issues in other Engines as well.

I created this github repo:

https://github.com/Light-Wizzard/Calculator

It examples what I want to do, let me know what you think, I will update the content soon, and post working examples for both math.js, and bignumber.js, and make separate projects for both, once I have working examples you will be better to judge if you should take me serious about my commitment to this project, keep in mind I am retired Military, I have PTST, and other issues as well as being an Aspie, my First Cousin was Isaac Newton and Benjamin Franklin, so I talk about them a lot, so I communicate with people a lot differently than most expect, most Normal People have a hard time following me in threads, I tend to give too much detail, information overload, and I have problems with things I do not understand, and have been a computer programmer since the 70's, born in 61, permanently retired in 2004, so I hope you understand what I am asking, I am not asking to make money off your project, I am asking for the Ability to show the World how to Make Money, and I will make my money the same way I show others how to, but at the same time, I need to prove it can be done and works, and that means I need to sell my Own App, and if you have no interest in selling one, then I can use my own Experience to write about, I will do this with or without your help, in fact I am not even asking for any help in that department, the opposite in fact, what I want to do is layout html based articles on how to do this, so everyone can do the same, and I can host this project myself and leave you two projects out completely if that is what you want, I can rewrite my page to reflex your decision, in a positive way, if you decide not to participate, I will just act like this conversation never took place, and write my project standalone, but I will still follow the same guild lines I set up there, asking everyone that uses it to donate to your projects, as that is my goal as well, and will not change, regardless of your participation, in fact it would be wise of you to just let this play out as is, leaving this issue open, not committing either way, this is wise, let it become community driven and support it as you can as it progresses, you two have been a huge help, and I really do appreciate your time, and at the moment, this project needs feet, I need to write all the examples, get the conversion from Qml to Web to work, get the bash script to work for all JavaScript Engines, and this takes time, so I really do not need any more help till that is finished, right now it just a dream, and content is King, so those finding this link, can follow and contribute if you want, at any point you like what you see, feel free to fork it, or just link to it, if you decide to actually sell it, I am not asking to be paid, I want that to be clear, I am only a Contributor to the Calculator code and that is Open Source, not the Math Library behind it, these are separate projects and most remain that way, I have no hidden agenda besides promoting my own Galaxy Calculator, and I do not intend to use this project to do so, it is just a by-product of the Produce that I am using as an Example, so my views and your views do not get mixed up, and the views of the Light Wizzard is based on Isaac Newton and Benjamin Franklin, so that is the views of my Family, and no one else's, Sir Isaac Newton was called the Last Magician, Magician translates to Wizard, and Newton wrote a book called Optics about Light, so he was the Light Wizard, and this is all about his Math, as well as my own Trinary Math, that I do, using your Library, that is the Math in the Galaxy Calculator, so it is real clear, why I use those terms, and one's like Sheeple, so you do not have any surprises about what Newton wrote about, which was mostly about the Bible, and my Galaxy Calculator proves that the Light without Darkness is what drives my Equations, but it was talk about Christ that got Newton Replaced by Albert Einstein who denounced his Theories after Nikola Tesla told a reported named Smith, that needs to prove his Theory or shut up about it, this was back in 1942 I think, anyway, it is public Domain, the Headlines read something about Einstein finding Religion, while Newton wrote about not believing in a Deity or Christ, and I have to mention to you this now, so you do not find out about it later, and wish you never answered any of my question, because some people have a real issue with what Newton proved in the Bible, like the End of Time in 2060, that is what my Galaxy Calculator calculates, people can argue about how I made the equation all they want, but not the numbers, http://lightwizzard.com/books/trinary.universe/appendix.g.html they are as close to what is acceptable, that most people will not try to argue them, this was XHTML was written using a bash script, and calculated using bc, and the more you learn about the numbers I used to calculate them, the more you will agree with the math formula, but not until then, so to associate with me, is like saying you know someone that was related to the Antichrist, because that is what most Christian's believe Newton was, and why they will not allow his teachings in any school in the World, while the Church buried him like Royalty, but my story is more than just about that, so you would be wise to understand it, before you decide if you even want to keep this issue open, so I ask to keep this a separate issue, so for the record, IAM the Light Wizzard in the Flesh: http://lightwizzard.com, but this project is just a by-product of that, and has nothing to do with promoting its views, but I cannot separate the only reason why I am using your Library, to do my Math, without disclosing who IAM, and I am proud of who I am, and what Newton wrote about, and I can also be found at the Vets Help Center since 1999: http://vetshelpcenter.com/about-vets.html, and you can FOIA the Government to confirm I am who I say I am, most people that say they were in Special Ops are phoney as hell, the Squadron is very small, everyone during that time I was stationed there, knows all about me, you could not miss me, I got an MS Medal, every few people get those, and that one is an part of an Oak Leaf Cluster, so the Government knows me as well, I have no reason to lie about anything, so I do not lie about anything, I just tell the truth, and if you agree with it, is beside the point, but it is a Historical Fact that my Trinary Math is based on all the greatest Wizards of our time, and they were all Aspies: Kepler, Galileo, Newton, Franklin, Tesla, Einstein, and others, but still most people think it is just bragging, but I am an Aspie, that is not really our thing, but Normal People think that people that are Autistic, are Stupid, FOIA my IQ, 99 means 100% correct, the scale does not go to 100, 50 is normal, below that is below average, I tested over 180 IQ, Einstein was only 160, and we are both Ashkenazi from the same regain in Germany, my parents migrated here back in the 16 and 17 hundreds, so we are Native Americans, and if Normal People allow this to influence their judgement, they will ignore my Equation for what it is, the truth about the Galaxy and all the Planets and Moons in it, they get to wrapped up in all the Politics, and Religion, to ever understand the Trinary Math that I wrote about: http://lightwizzard.com/books/trinary.universe/chapter.4.12.html, this chapter is old now, I have a new version to post, but it is waiting on this app to be finished, before I post it.

The Reason I tell people this is, is called being up front, to not tell you is called a Hidden Agenda, and I do not like this, any more than those that fall into that game, I do not care what you think about me, this Project is not about me, but the Galaxy Calculator is the only reason I am doing this, and it is what it is, and will causes issues for some people, because it is based on Newton, and my First Cousin has the same last Name as I do, most people can understand what a First Cousin is, others do not, so see the Reference Page, and if you do not believe it, prove it one way or the other before you doubt it, all my information is verifiable, so I am who I say I am, and have no idea why some people find this so hard to believe, yet I get people that only want to argue with me, and bury my work, as well as Newtons, when the fact is, that you cannot use Newtons Math in the Dynamic Universe, since it is based on the Force of Gravity being the Light of God, and the Dynamic Universe is Godless, and why Einstein denounced it, why people believe in a Theory the Author told you is a Lie, is another issue, my Madness Meter address this issues, and some people are offended by it, when that is what Jesus said, God is All Light without Darkness, and that is what drives my Equations.

Sorry about the long explanation, but I also was diagnosed with OCD, and tend to be this way just because I am Autistic, and I am not Normal, and I do have a hard time communicating with Normal People, and that is the reason I asked you guys to take this over, so we can leave all this part out of this project, just by being in any of my repos, it pulls all that debate in, and I do not want to debate Newton or Tesla, like Einstein, I only believe in them, and not Theory that has never been proven.

Thanks

josdejong commented 5 years ago

Cool, I'm curious to see how your bash script will work out. Maybe you can write it in JavaScript instead of bash, I think that's more powerful?

Sorry about the long explanation, but I also was diagnosed with OCD, and tend to be this way just because I am Autistic

ahh, now I understand your long explanations. I haven't seen topics this long, you really hold the record for that ;)

See also: #1473

Light-Wizzard commented 5 years ago

I will write my Calculator app to make the changes and test them, so I will do it all in JavaScript, that is a good Idea, thanks.

josdejong commented 5 years ago

:+1: I will close this issue now since there is no action required for mathjs itself but feel free to keep us posted :)