strict

浏览器的两种模式quirks mode 和strict mode

試著忘記壹切 提交于 2019-12-05 03:43:06
在看js代码时,有时会看到关于quirks mode(怪异模式)和strict mode(严格格式)的东西,一直也没深究怎么回事,只是零零碎碎的有些概念,最近终于受不了这种似懂非懂的感觉,决定好好学习总结一下。 1、quirks mode和strict mode是浏览器解析css的两种模式,或者可以称之为解析方法。目前正在使用的浏览器这两种模式都支持 。 2、历史原因。 当早期的浏览器Netscape 4和Explorer 4对css进行解析时,并未遵守W3C标准,这时的解析方式就被我们称之为quirks mode(怪异模式),但随着W3C的标准越来越重要,众多的浏览器开始依照W3C标准解析CSS,仿照W3C标准解析CSS的模式我们叫做strict mode(严格模式). 3、后来的浏览器虽然支持strict mode,但众多浏览器并未放弃支持quirks mode。 一个重要的原因就是为了之前大量在quirks mode下开发的网页能够得到正确的显示。所以,这些支持两种模式的浏览器当拿到一张网页时,所做的一个前期工作就是判断采取何种方式进行解析(判断条件后面会说)。注:Explorer 5仍然只支持quirks mode 4、浏览器如何判断何用哪种方式解析CSS? 解决方案就是采用doctype声明,大多数浏览器采用下面的这些 判断规则 浏览器要使老旧的网页正常工作

Haskell: Guidelines for using Strictness

只愿长相守 提交于 2019-12-05 01:41:30
Is there any recommend guidelines when to use strictness in Haskell ? For example, I was looking on the tagsoup library. They have one of their data structure defined like this: data Tag str = TagOpen str [Attribute str] | TagClose str | TagText str | TagComment str | TagWarning str | TagPosition !Row !Column type Row = Int type Column = Int So on what factor exactly do they decide that TagPosition should be strict ? Are there any recommend guidelines for this ? For simple, unstructured datatypes such as Int or Double , turning them into strict fields is often a good default. That makes their

Time cost of Haskell `seq` operator

戏子无情 提交于 2019-12-04 17:36:35
问题 This FAQ says that The seq operator is seq :: a -> b -> b x seq y will evaluate x, enough to check that it is not bottom, then discard the result and evaluate y. This might not seem useful, but it means that x is guaranteed to be evaluated before y is considered. That's awfully nice of Haskell, but does it mean that in x `seq` f x the cost of evaluating x will be paid twice ("discard the result")? 回答1: The seq function will discard the value of x , but since the value has been evaluated, all

Should I worry about “window is not defined” JSLint strict mode error?

我只是一个虾纸丫 提交于 2019-12-04 16:28:09
问题 This won't pass JSLint in strict mode: "use strict"; (function (w) { w.alert(w); }(window)); The error--from jslint.com--looks like this: Problem at line 4 character 3: 'window' is not defined. }(window)); Implied global: window 4 Do I need to tell JSLint to ignore the error, or am I seriously doing something wrong? 回答1: Try adding the following: /*jslint browser: true */ /*global window */ (or check Assume a browser checkbox). The first line adds general browser support. The second line

Javascript: besides “use strict”, which other “use” directives are there?

那年仲夏 提交于 2019-12-04 08:10:16
Besides use strict , which other use directives are there? GitaarLAB Some more examples that can be in the “directive prologue” (a section potentially usable by JavaScript engines): 'use strict'; 'use asm'; Mozilla's asm.js is a subset of the language, geared towards crunching numbers. 'use stricter'; Google's SoundScript. For fast OOP Has also some modes like: 'use stricter+types'; http://www.2ality.com/2015/02/soundscript.html 'use babel'; Used in Atom.io . (Was previously: 'use 6to5'; ) A tweet by Jeremy Ashkenas suggests some further use of + and - prefixes in the same 'use ...'; string (

JavaScript: Can ECMAScript 5's Strict Mode (“use strict”) be enabled using single quotes ('use strict')?

删除回忆录丶 提交于 2019-12-03 22:03:35
JavaScript doesn't care if your Strings are double-quoted "double" or single-quoted 'single' . Every example of ECMAScript 5's strict mode has it enabled by "use strict" in double-quotes. Can I do the following (single-quotes): alert(function(){ 'use strict'; return !this; }()); This will return true if Strict mode is enabled, and false if it is not. Felix Kling For you, without using a browser that supports strict mode : A Use Strict Directive is an ExpressionStatement in a Directive Prologue whose StringLiteral is either the exact character sequences "use strict" or 'use strict' . A Use

Time cost of Haskell `seq` operator

江枫思渺然 提交于 2019-12-03 11:15:56
This FAQ says that The seq operator is seq :: a -> b -> b x seq y will evaluate x, enough to check that it is not bottom, then discard the result and evaluate y. This might not seem useful, but it means that x is guaranteed to be evaluated before y is considered. That's awfully nice of Haskell, but does it mean that in x `seq` f x the cost of evaluating x will be paid twice ("discard the result")? The seq function will discard the value of x , but since the value has been evaluated, all references to x are "updated" to no longer point to the unevaluated version of x , but to instead point to

GCC options for strictest C code? [duplicate]

我只是一个虾纸丫 提交于 2019-12-03 08:35:26
问题 This question already has answers here : Recommended gcc warning options for C [closed] (15 answers) Closed 5 years ago . What GCC options should be set to have GCC as strict as possible? (and I do mean as strict as possible) I'm writing in C89 and want my code to be ANSI/ISO compliant. 回答1: I'd recommend using: -Wall -Wextra -std=c89 -pedantic -Wmissing-prototypes -Wstrict-prototypes \ -Wold-style-definition You should compile with -O as well as -g as some warnings are only available when

Does python have a “use strict;” and “use warnings;” like in perl?

馋奶兔 提交于 2019-12-03 07:21:20
问题 I am learning perl and python... at the same time, not my by design but it has to be done. Question: In a perl script I use(see below) at the head of my txt. #!/usr/bin/env perl use strict; use warnings; Is there something I should be doing on routine for my python scripts? 回答1: To provide an answer that perhaps avoids a little of the commentary noise here, I'll try another one. The two pragmata in your original question really expand to: use strict "vars"; use strict "refs"; use strict "subs

GCC options for strictest C code? [duplicate]

ε祈祈猫儿з 提交于 2019-12-02 22:22:22
This question already has an answer here: Recommended gcc warning options for C [closed] 15 answers What GCC options should be set to have GCC as strict as possible? (and I do mean as strict as possible) I'm writing in C89 and want my code to be ANSI/ISO compliant. Jonathan Leffler I'd recommend using: -Wall -Wextra -std=c89 -pedantic -Wmissing-prototypes -Wstrict-prototypes \ -Wold-style-definition You should compile with -O as well as -g as some warnings are only available when the optimizer is used (actually, I usually use -O3 for spotting the problems). You might prefer -std=gnu89 as that