2,986 reputation
1024
bio website
location Lübeck, Germany
age 27
visits member for 3 years, 6 months
seen 7 hours ago

Feb
4
awarded  Nice Answer
Jan
30
awarded  Nice Answer
Oct
21
awarded  Good Answer
Sep
23
awarded  Yearling
Jun
9
comment How do purely functional languages handle modularity?
The term "purely functional" refers to functional languages that maintain referential transparency and is unrelated to whether or not the language has any object oriented features.
Jun
2
comment Is this a viable approach to resolving multiple matches in a lexer?
@DocBrown First of all adding support for lookahead assertions to lexer generators (which I think is what you're suggesting - unless I misunderstood), would mean a lot of additional development effort just to offer an alternative to a rule that already works perfectly fine. But even more importantly, it seems to me that manually specifying where a token should end would just be more complicated and error prone. For example I would imagine that a common error would be that people forget to specify that a token may appear at the end of the file.
Jun
2
comment Is this a viable approach to resolving multiple matches in a lexer?
@DocBrown That's not how it's usually done, no. The usual rule for identifiers is [a-zA-Z_][a-zA-Z_0-9]* and the usual rule for a keyword like var would simply be var. In fact, as far as I know, most lexer generators don't even offer a way of saying "This token should be separated by this kind of character from the surrounding text".
Jun
2
answered Is this a viable approach to resolving multiple matches in a lexer?
May
20
awarded  Good Answer
Apr
23
comment What arguments are there in favor of weak typing?
@Basic Unless "dynamically/strongly" typed means something other than "dynamically typed and strongly typed" (which I don't see how it could), your second sentence directly contradicts your first.
Apr
18
comment Why is sizeof called a compile-time operator?
Actually, if you use sizeof on an array, you will get the size of the array (that is the element size times the number of elements). But if you use it on a pointer, you only get the size of the pointer. So, since in most cases where you'd like to know the size of an array, you only have a pointer, it's not all that useful.
Mar
18
awarded  Informed
Mar
11
comment implement cons function in Java - type safety question
@LukeMurphy I just realized it has to be YourClass.<T>cons even if YourClass is the current class. Does that work? If no, please post your whole code, so I can try to compile it myself.
Mar
11
comment implement cons function in Java - type safety question
@LukeMurphy <T> cons() does not work?
Mar
11
comment implement cons function in Java - type safety question
@LukeMurphy Ah, you might have to give type parameters to cons as well.
Mar
11
comment implement cons function in Java - type safety question
@Luke Oh, you're right I read it wrong. Sorry. The real problem is that new EmptyList is missing the type parameter - I think. If that's not it, post the error message you get without the cast. And what I meant by it being hard coded is that you should have one version that can handle any possible result type (using a second type parameter).
Mar
11
comment implement cons function in Java - type safety question
@LukeMurphy And it isn't really accurate to say "I have to use a cast" as that would imply the cast works, which I'm pretty sure it won't.
Mar
11
comment implement cons function in Java - type safety question
@LukeMurphy Hard-coding the result type of foldl to List<T> doesn't seem like a good idea. Anyway your problem is that the function given to fold takes a list and a T, while cons takes a T and a list. So you either need to reverse the order in which the function given to fold takes its argument, the order in which cons takes its arguments or define a flip function and pass flip cons as the function argument to foldl.
Mar
11
revised implement cons function in Java - type safety question
deleted 3 characters in body
Mar
11
revised implement cons function in Java - type safety question
added 110 characters in body