Questions tagged [strict]

Mode used in languages such as Javascript and Perl to be able to code with a restricted version of those languages.

451 questions
304
votes
5 answers

How do I break out of a loop in Perl?

I'm trying to use a break statement in a for loop, but since I'm also using strict subs in my Perl code, I'm getting an error saying: Bareword "break" not allowed while "strict subs" in use at ./final.pl line 154. Is there a workaround for…
Zain Rizvi
  • 21,625
  • 17
  • 82
  • 122
209
votes
1 answer

Not recommended to use "use strict" in ES6?

I'm not familiar with ECMAScript 6 yet. I've just cloned the React Starter Kit repo, which uses ES6 for application code. I was surprised to see that the linter is configured to forbid occurences of the use strict directive, which I thought was…
Midiparse
  • 4,441
  • 4
  • 25
  • 44
175
votes
7 answers

PHP 5 disable strict standards error

I need to setup my PHP script at the top to disable error reporting for strict standards. Can anybody help ?
Manny Calavera
  • 6,379
  • 20
  • 57
  • 84
98
votes
4 answers

Why is JSHINT complaining that this is a strict violation?

I think this may be a duplicate of Strict Violation using this keyword and revealing module pattern I have this code: function gotoPage(s){ if(s<=this.d&&s>0){this.g=s; this.page((s-1)*this.p.size);} } function pageChange(event, sorter) { …
Cheeso
  • 180,104
  • 92
  • 446
  • 681
81
votes
6 answers

Error message "Strict standards: Only variables should be passed by reference"

$el = array_shift($instance->find(..)) The above code somehow reports the strict standards warning, but this will not: function get_arr(){ return array(1, 2); } $el = array_shift(get_arr()); So when will it report the warning anyway?
user198729
  • 55,886
  • 102
  • 239
  • 342
57
votes
6 answers

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

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…
jon_shep
  • 1,313
  • 3
  • 14
  • 24
53
votes
3 answers

Strict Violation using this keyword and revealing module pattern

Having trouble getting the following to pass jslint/jshint /*jshint strict: true */ var myModule = (function() { "use strict"; var privVar = true, pubVar = false; function privFn() { return this.test; // -> Strict…
Matty F
  • 3,704
  • 2
  • 27
  • 46
44
votes
2 answers

the seq function and strictness

I have been wondering about this a lot, but I haven't been able to find anything about it. When using the seq function, how does it then really work? Everywhere, it is just explained saying that seq a b evaluates a, discards the result and returns…
Undreren
  • 2,581
  • 17
  • 31
41
votes
4 answers

In ECMAScript5, what's the scope of "use strict"?

What scope does the strict mode pragma have in ECMAScript5? "use strict"; I'd like to do this (mainly because JSLint doesn't complain about it): "use strict"; (function () { // my stuff here... }()); But I'm not sure if that would break other…
Stephen Sorensen
  • 9,969
  • 11
  • 29
  • 42
39
votes
3 answers

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

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(){ …
Rudiger
  • 401
  • 4
  • 5
34
votes
4 answers

Which (javascript) environments support ECMAscript 5 strict mode? (aka "use strict")

ECMAScript 5 is in its final draft as I write this; It is due to include a strict mode which will prevent you from assigning to the global object, using eval, and other restrictions. (John Resig's Article is a good introduction.) This magical…
Sean McMillan
  • 9,718
  • 5
  • 52
  • 62
28
votes
3 answers

Would this enable "use strict" globally?

Similar, but not the same as, How to enable ECMAScript "use strict" globally? I have bought JavaScript Patterns and it recommends enabling use strict. Adding it to the two dozen javascript files would be a bit of a chore, so enabling it globally…
graham.reeds
  • 15,267
  • 16
  • 66
  • 133
26
votes
4 answers

Can comments come before `use strict;`?

I've seen a few places around the internet passively stating 'use strict;' must come on the first line of the functional scope for which you want the behavioral directive to apply. However, in my experience, it doesn't matter if there are comments…
Qix - MONICA WAS MISTREATED
  • 12,202
  • 13
  • 73
  • 131
25
votes
6 answers

How to turn off MySQL strict mode in Rails

Upgrading to Rails 4, it seems MySQL strict mode is now on by default for Rails connections. I say this because my Rails app is getting "Mysql2::Error: Data too long for column" when saving a string value longer than 255 characters. Yet, I paste the…
mahemoff
  • 38,430
  • 30
  • 133
  • 196
23
votes
5 answers

Convert a Lazy ByteString to a strict ByteString

I have a function that takes a lazy ByteString, that I wish to have return lists of strict ByteStrings (the laziness should be transferred to the list type of the output). import qualified Data.ByteString as B import qualified Data.ByteString.Lazy…
Matt Joiner
  • 100,604
  • 94
  • 332
  • 495
1
2 3
30 31