What is the difference between Object Literals and Array Literals in JavaScript? I know it has something to do with the length method but i don't fully understand it.
GWT.create() is the reflection equivalent in GWT,
But it take only class literals, not fully qualified String for the Class name.
How do i dynamically create classes with Strings using GWT.create()?
Its not possible according to many GWT forum posts but how is it being done in frameworks like Rocket-GWT (http://code.google.com/p/rocket-gwt/wiki/Ioc) and Gwittir (http://code.google.com/p/gwittir/wiki/Introspection)
UPDATE: It turns out this is a deeper question than I thought at first glance - the issue is that python is replacing the string literals before they ever get to django. I will do more investigating and update this if I find a solution.
I'm using django to work with LaTeX templates for report generation, and am running into a lot of problems with the way Django replaces parts of strings.
Specficially, I've run into two problems where I try to insert a variable containing latex code.
The first was that it would replace HTML characters, such as the less than symbol, with their HTML codes, which are of course gibberish to a LaTeX interpreter. I fixed this by setting the context to never autoescape, like so:
c = Context(inputs)
c.autoescape = False
However, I still have my second issue, which is that Django replaces string literals with their corresponding characers, so a double backslash becomes \, and \b becomes a backspace. How can I force Django to leave these characters in place, so
inputs['variable'] = '{\bf this is code} \\'
won't get mangled when I use
{{variable}}
to reference it in the django template?
So, I'm wanting to get a better grasp on how string literals in C++ work. I'm mostly concerned with situations where you're assigning the address of a string literal to a pointer, and passing it around. For example:
char* advice = "Don't stick your hands in the toaster.";
Now lets say I just pass this string around by copying pointers for the duration of the program. Sure, it's probably not a good idea, but I'm curious what would actually be going on behind the scenes.
For another example, let's say we make a function that returns a string literal:
char* foo()
{
// function does does stuff
return "Yikes!"; // somebody's feeble attempt at an error message
}
Now lets say this function is called very often, and the string literal is only used about half the time it's called:
// situation #1: it's just randomly called without heed to the return value
foo();
// situation #2: the returned string is kept and used for who knows how long
char* retVal = foo();
In the first situation, what's actually happening? Is the string just created but not used, and never deallocated?
In the second situation, is the string going to be maintained as long as the user finds need for it? What happens when it isn't needed anymore... will that memory be freed up then (assuming nothing points to that space anymore)?
Don't get me wrong, I'm not planning on using string literals like this. I'm planning on using a container to keep my strings in check (probably std::string). I'm mostly just wanting to know if these situations could cause problems either for memory management or corrupted data.
Session[Constant] vs Session["String Literal"] Performance
I'm retrieving user-specific data like ViewData["CartItems"] = Session["CartItems"]; with a string literal for keys on every request. Should I be using constants for this?
If yes, how should I go about implementing frequently used string literals and will it significantly affect performance on a high-traffic site?
Related question does not address ASP.NET MVC or Session.
I have read a lot of posts about "string literals" on SO, most of which have been about best-practices, or where the literal is NOT located in memory.
I am interested in where the string DOES get allocated/stored, etc.
I did find one intriguing answer here, saying:
Defining a string inline actually embeds the data in the program itself and cannot be changed (some compilers allow this by a smart trick, don't bother).
but, it had to do with C++, not to mention that it says not to bother.
I am bothering. =D
So my question is, again, where and how is my string literal kept? Why should I not try to alter it? Does the implementation vary by platform? Does anyone care to elaborate on the "smart trick?"
Thanks for any explanations.
In this post, Martin (the language's head honcho) writes:
[XML literals] Seemed a great idea at the
time, now it sticks out like a sore thumb. I believe with the new
string interpolation scheme we will be able to put all of XML
processing in the libraries, which should be a big win.
Being interested in language design myself, I'm wondering: Why does he write that it was a mistake to incorporate XML literals into the language? What is the controversy regarding this feature?
One of the common use-cases of XML literals is creating HTML. However, HTML entities cannot be used in XML literals since LINQ to XML directly supports only the Data type definitions (DTD) defined in the XML 1.0 spec. You can read more about it here. The workaround is to use the Unicode representation of the entity, although its not as readable as the HTML entities, the output is the same. Here are two examples of HTML entities from the XHTML spec : Entity...Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.
One of the common use-cases of XML literals is creating HTML. However, HTML entities cannot be used in XML literals since LINQ to XML directly supports only the Data type definitions (DTD) defined in the XML 1.0 spec. You can read more about it here. The workaround is to use the Unicode representation of the entity, although its not as readable as the HTML entities, the output is the same. Here are two examples of HTML entities from the XHTML spec : Entity...Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.
XML Literals allow you to use XML syntax in your code. It’s easy to work with XML files this way, since you have that Tags in the code, but it’s also quicker to access information rather then the traditional methods.
XML Literals allow you to use XML syntax in your code. Its easy to work with XML files this way, since you have that Tags in the code, but its also quicker to access information rather then the traditional methods....Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.
I'm retrieving an array of objects from a hidden html input field. The string I'm getting is:
"{"id":"1234","name":"john smith","email":"[email protected]"},{"id":"4431","name":"marry doe","email":"[email protected]"}"
Now I need to pass this as an array of objects again. How do I convert this string into array of objects?
I'm retrieving an array of objects from a hidden html input field. The string I'm getting is:
"{"id":"1234","name":"john smith","email":"[email protected]"},{"id":"4431","name":"marry doe","email":"[email protected]"}"
Now I need to pass this as an array of objects again. How do I convert this string into array of objects?
The implicit line continuation feature in Visual Basic 2010 provided an opportunity to improve the code editing experience in XML literals embedded expressions. In Visual Studio 2008, pressing Enter inside an embedded expression would result in the cursor being positioned to the left of the end embedded expression tag. In Visual Studio 2010, pressing Enter inserts a newline for the cursor, and the end embedded expression tag moves to the line below. This minimizes the number of key strokes needed...Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.
This question is being asked because of this one.
C++11 allows you to define literals like this for numeric literals:
template<char...> OutputType operator "" _suffix();
Which means that 503_suffix would become <'5','0','3'>
This is nice, although it isn't very useful in the form it's in.
How can I transform this back into a numeric type? This would turn <'5','0','3'> into a constexpr 503. Additionally, it must also work on floating point literals. <'5','.','3> would turn into int 5 or float 5.3
A partial solution was found in the previous question, but it doesn't work on non-integers:
template <typename t>
constexpr t pow(t base, int exp) {
return (exp > 0) ? base * pow(base, exp-1) : 1;
};
template <char...> struct literal;
template <> struct literal<> {
static const unsigned int to_int = 0;
};
template <char c, char ...cv> struct literal<c, cv...> {
static const unsigned int to_int = (c - '0') * pow(10, sizeof...(cv)) + literal<cv...>::to_int;
};
// use: literal<...>::to_int
// literal<'1','.','5'>::to_int doesn't work
// literal<'1','.','5'>::to_float not implemented
Session[Constant] vs Session["String Literal"] Performance
I'm retrieving user-specific data like ViewData["CartItems"] = Session["CartItems"]; with a string literal for keys on every request. Should I be using constants for this?
If yes, how should I go about implementing frequently used string literals and will it significantly affect performance on a high-traffic site?
Related question does not address ASP.NET MVC or Session.
Entity SQL might surprise you if you are building query expressions with some non-string types. Ive blogged about this before with the DateTime literal after trying to use a string to represent the date in my query as Im used to with TSQL. Here is a snip from that post: SELECT VALUE BAModel.Contact(c.ContactID,c.FirstName,c.LastName,c.Title,c.AddDate,c.ModifiedDate) FROM dbo.Contact as c WHERE c.AddDate>="1/1/2007" I was trying to emulate T-SQL here but I need...Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.
Probably known by most programmers, but I want to document it so I can find it myself later.An easy way to create a multiline VB string is to create a xml literal and use the valueDim myTest = <string>Here is a multiline string that I want to use insome other code. Ithelps the readability andcut and paste functionality.Even if this is a poor example</string>Dim strInside as string = myTest.value
There is a partial answer on Stack Overflow, but I'm asking something a teeny bit more specific than the answers there.
So... Does the formal semantics (Section 7.2) specify the meaning of such a numeric literal? Does it specify the meaning of numeric operations on the value resulting from interpreting the literal?
If yes, what are the meanings (in English -- denotational semantics is all greek characters to me :))?
I was going through the spark view engine documentation and found a lot of literals showing up in code for which I couldn’t find any references. For e.g.
! , #, $ , !$ , ...
What are these for? What do the combinations mean? When do they come into use? Am I missing any more literals that precede or comes after {
How many significant digits should I use when defining a double literal in Java? This is assuming that I am trying to represent a number with more significant figures than a double can hold.
In Math.java I see 20 and 21:
public static final double E = 2.7182818284590452354;
public static final double PI = 3.14159265358979323846;
This is more than the 15-17 significant digits provided by IEEE 754. So what's the general rule-of-thumb?
I'm referring to the syntax for writing strings in code, including multiline strings and verbatim strings.
(Context: I'm working on a tool that scans code, and it's important to determine when tokens are inside a string.)
Thanks!
Hello everyone :)
I've got a bit of a problem. Essentially, I need to store a large list of whitelisted entries inside my program, and I'd like to include such a list directly -- I don't want to have to distribute other libraries and such, and I don't want to embed the strings into a Win32 resource, for a bunch of reasons I don't want to go into right now.
I simply included my big whitelist in my .cpp file, and was presented with this error:
1>ServicesWhitelist.cpp(2807): fatal error C1091: compiler limit: string exceeds 65535 bytes in length
The string itself is about twice this allowed limit by VC++. What's the best way to include such a large literal in a program?