• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 08:48
CEST 14:48
KST 21:48
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
[ASL19] Finals Recap: Standing Tall9HomeStory Cup 27 - Info & Preview18Classic wins Code S Season 2 (2025)16Code S RO4 & Finals Preview: herO, Rogue, Classic, GuMiho0TL Team Map Contest #5: Presented by Monster Energy6
Community News
Flash Announces Hiatus From ASL62Weekly Cups (June 23-29): Reynor in world title form?13FEL Cracov 2025 (July 27) - $8000 live event21Esports World Cup 2025 - Final Player Roster16Weekly Cups (June 16-22): Clem strikes back1
StarCraft 2
General
Program: SC2 / XSplit / OBS Scene Switcher The SCII GOAT: A statistical Evaluation Statistics for vetoed/disliked maps Weekly Cups (June 23-29): Reynor in world title form? PiG Sty Festival #5: Playoffs Preview + Groups Recap
Tourneys
RSL: Revival, a new crowdfunded tournament series Sparkling Tuna Cup - Weekly Open Tournament WardiTV Mondays FEL Cracov 2025 (July 27) - $8000 live event Korean Starcraft League Week 77
Strategy
How did i lose this ZvP, whats the proper response Simple Questions Simple Answers
Custom Maps
[UMS] Zillion Zerglings
External Content
Mutation # 480 Moths to the Flame Mutation # 479 Worn Out Welcome Mutation # 478 Instant Karma Mutation # 477 Slow and Steady
Brood War
General
Player “Jedi” cheat on CSL SC uni coach streams logging into betting site Flash Announces Hiatus From ASL Practice Partners (Official) ASL20 Preliminary Maps
Tourneys
[BSL20] Grand Finals - Sunday 20:00 CET [Megathread] Daily Proleagues Small VOD Thread 2.0 [BSL20] GosuLeague RO16 - Tue & Wed 20:00+CET
Strategy
Simple Questions, Simple Answers I am doing this better than progamers do.
Other Games
General Games
Path of Exile Stormgate/Frost Giant Megathread Nintendo Switch Thread What do you want from future RTS games? Beyond All Reason
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
Russo-Ukrainian War Thread US Politics Mega-thread Summer Games Done Quick 2025! Trading/Investing Thread Things Aren’t Peaceful in Palestine
Fan Clubs
SKT1 Classic Fan Club! Maru Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece [\m/] Heavy Metal Thread
Sports
2024 - 2025 Football Thread Formula 1 Discussion NBA General Discussion TeamLiquid Health and Fitness Initiative For 2023 NHL Playoffs 2024
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Blogs
Culture Clash in Video Games…
TrAiDoS
from making sc maps to makin…
Husyelt
Blog #2
tankgirl
StarCraft improvement
iopq
Trip to the Zoo
micronesia
Customize Sidebar...

Website Feedback

Closed Threads



Active: 629 users

The Big Programming Thread - Page 76

Forum Index > General Forum
Post a Reply
Prev 1 74 75 76 77 78 1031 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
Frigo
Profile Joined August 2009
Hungary1023 Posts
Last Edited: 2011-09-05 13:05:57
September 05 2011 13:04 GMT
#1501
It's a bit of misnomer, it returns a T& reference to the stored object (or throws an exception if the pointer is null). Both operations are on references. Naming is kinda taken from std:: reference_wrapper.

I think it would be wiser to implement it the second way, that only the reference wrapper gets modified. Less headaches with immutable types, threads, unintended consequences.

However, operator + might not return T. Damn. This can complicate things in the second case, with the plain operator +. However in that case I am not obligated to return ref<T> in the proxy. Only the += is problematic since I need to return ref<T>&.

I'll get some sleep over this, hopefully I will come up with a satisfying solution.
http://www.fimfiction.net/user/Treasure_Chest
Deleted User 101379
Profile Blog Joined August 2010
4849 Posts
September 05 2011 13:33 GMT
#1502
Basically, if operator overloading is used, anything can happen.

The innocent line
a += 1;
could be an overloaded += operator that initiates nuclear warfare.

Also, the lines
a += 1
could increase a by 1 while
a = a + 1
could decrease a by 10.

This is one of the reasons why java removed operator overloading completely (I don't agree with that decision, but it wasn't totally unreasonable).

If you use operator overloading or use classes that do it, always read the documentation (or in case of the usual lack of it, the code). Otherwise there is no way to really know what will happen. Avoid it as much as possible unless the benefits are far greater than the possible pitfalls for this specific scenario.
EscPlan9
Profile Blog Joined December 2006
United States2777 Posts
Last Edited: 2011-09-05 14:06:55
September 05 2011 13:53 GMT
#1503
On September 03 2011 09:16 Neshapotamus wrote:
EscPlan9, I dont understand your post at all. First off, if you have a WSDL, cant you generate a webservice proxy and use strongly typed object. If that approach doesnt work out and sounds like your getting XML, do you have the XSD for the XML. That way, you can serialize and deserialize the XML into a object. If you dont want to do it that way, can't you use LINQ to XML to and create a annonoymous object with the name for the property you would want.

Maybe, an example of what your trying to do and I can be more clear on taking the best approach.


Fair enough. I have no prior experience with WSDLs - I've just been working with them as if they are XML files. So to be frank, I do not understand the majority of your post either.

The previous developer (no longer with the company) used SvcUtil on the WSDL to generate the client proxy. I originally was tackling the problem through straight XML parsing methods, most recently XPATH. But I figure I really shouldn't be reinventing the wheel when he already figured out a reliable way of parsing the WSDL for the important information he needs. I just know going through his code gives me major headaches trying to understand what he's doing in the sections (no documentation, no comments, code works but is ugly as hell), but I digress...

I'll look into finding the schema (XSD) for the WSDLs. Though I do not yet understand what I should be getting from serializing/deserializing the XMLs (zero experience with that), or how to make use of that information.

As for the last point, I haven't touched LINQ yet. I know SQL and it seems fairly similar in syntax.

The current plan going forward:
1) Take more time to understand how SvcUtil was used on the WSDLs previously.
2) Take more time for planning and design once I understand the organization of the information returned from the SvcUtil generated client proxy.
3) Create new methods to send that information to the (WIP) GUI frontend and generate the tree structure.

A simplified dummy WSDL I created (from the top of my head while at home) that's similar to the WSDLs being analyzed:

<wsdlMe>
<complexType name="Create">
<element name="Items" type="tns:Items" maxOccurs="unbounded"></element>
<element name="Username" type="string"></element>
</complexType>

<complexType name="Items">
<element name="Description" type="string"></element>
<element name="Quantity" type="int"></element>
<element name="Price" type="decimal"></element>
</complexType>

<complexType name="CreateResponse">
<element name="Errors" type="tns:Errors" maxOccurs="unbounded"></element>
</complexType>

<complexType name="Errors">
<element name="Description" type="string"></element>
</complexType>

<complexType name="Finish">
<element name="Time" type="datetime"></element>
</complexType>

<complexType name="FinishResponse">
<element name="Errors" type="tns:Errors" maxOccurs="unbounded"></element>
</complexType>

<messages>
<message name="CreateMsgIn" type="tns:Create"></message>
<message name="CreateMsgOut" type="tns:CreateResponse"></message>
<message name="FinishMsgIn" type="tns:Finish"></message>
<message name="FinishMsgOut" type="tns:FinishResponse"></message>
</messages>

<portType>
<operations>
<operation name="Create" type="tns:CreateMsg"></operation>
<operation name="Finish" type="tns:FinishMsg"></operation>
</operations>
</portType>
</wsdlMe>


The QA tester selects the operation they want to create a test case for. Then the WSDL is parsed (portType/operations/operation) to create the tree structure for the user. So they would see something like

(operation selected is Create)
Create
--CreateMsg
----CreateMsgIn
------Create
--------Items
-----------Description
-----------Quantity
-----------Price
--------Username
----CreateMsgOut

... etc

I've been experimenting with using a Dictionary <string, TreeNode> to hold the information on the tree structure.
Key = child-node-name(string)
Value = parent-node (treenode)

So then when adding a treenode, it's something like

// create new node
TreeNode newNode = new TreeNode(childNodeName);
// get parent node
TreeNode prevNode = dictionary[parentNodeName];
// add child to parent node within tree
prevNode.Nodes.Add(newNode);


I'm pretty stressed that I've wasted a lot of time due to my inexperience here. Thankfully it isn't a high priority at the company? Either way, I've certainly come to appreciate taking more time for designing and planning ahead of time before coding.

(This post was more made to clarify what I'm working on, than to specifically ask questions. Feel free to comment on whatever anyways)
Undefeated TL Tecmo Super Bowl League Champion
pettter
Profile Joined December 2009
Sweden1032 Posts
September 05 2011 14:01 GMT
#1504
Actually, operator overloading, used correctly, is more obvious and less prone to errors than .plus() shenanigans, due to having a well-defined order of precedence without resorting to masses of parentheses. Still, as many (most?) advanced features of C++, it can be horribly, horribly misused as well.

A couple of really hairy combination is a) the combination of multiple inheritance and operator overloading and b) the combination of dynamic typing and operator overloading. Having well-defined types of your variables is absolutely crucial to proper usage of operator overloading.

As for the current problem, the second variant would seem more reasonable, but keep in mind that users may have selected x += y as opposed to x = x + y precisely because they want to change x the object, not x the reference. See [section 13.9 here for example.

It mostly comes down to: comment your damn code, and use const liberally to demonstrate which values change and which do not.
Frigo
Profile Joined August 2009
Hungary1023 Posts
September 05 2011 21:00 GMT
#1505
On September 05 2011 22:33 Morfildur wrote:
This is one of the reasons why java removed operator overloading completely (I don't agree with that decision, but it wasn't totally unreasonable).

Yeah, there are a few heavy abuses of operator overloading but that's no reason to forbid them completely. They are vital to numerical calculations (just as custom value types but that's another story...). They have well defined precedence and can greatly simplify expressions and make them much more transparent. Even if they don't allow full overloading, operators could be aliases for member functions, for example x + y could simply call x.add(y). I believe there is a Java precompiler that does such.

A method can be just as bad as an operator. Undocumented, in violation of contract, malicious. The common reasoning against operators can be applied to methods as well: an add() method might not have anything to do with addition, it could call launchNuclearMissile() just as easily as an operator. They should be treated like methods, with the same scrutiny applied to them. Complete with firing the programmer who abuses operators

If you use operator overloading or use classes that do it, always read the documentation (or in case of the usual lack of it, the code). Otherwise there is no way to really know what will happen. Avoid it as much as possible unless the benefits are far greater than the possible pitfalls for this specific scenario.

Yup, that's the problem here. I do not have a definite class to just look at how it implements operators. Both binary and compound assignment operators might return T, T*, T&, const T& or even a completely unrelated type. The best approach in my case would be to limit the return types to a few correct cases, and use partial template specialization to override this best-guess behavior when it can't model a case properly.
http://www.fimfiction.net/user/Treasure_Chest
0x64
Profile Blog Joined September 2002
Finland4546 Posts
September 05 2011 21:36 GMT
#1506
today I run into a very strange bug with a java midlet app.
I have a base class A and two derived class of A, say B and C.

the problem was with constructor.

A(int n) {
foo = new Plop[n]
}

B() {
super(10);
initFoos();
}

C() {
super(12);
initFoos();
}

----
Now the thing is when I would call initFoos for C, it would crash with out of bound after 10 elements on one device. And work properly on another device...
Just wondering if someone really experienced have deeper knowledge of possible ambiguities.
I have 10 years of work in the field, so I know better not to blame anything else than my code (in this case one of my workers.. ).
We did a work around but I'm not happy about that.
Dump of assembler code from 0xffffffec to 0x64: End of assembler dump.
Frigo
Profile Joined August 2009
Hungary1023 Posts
Last Edited: 2011-09-05 21:56:50
September 05 2011 21:42 GMT
#1507
From the sound of it, C.initFoos() does not give a flying fuck about foo.length (or even modifies foo).

Give us more code, it is difficult to tell the problem from a few lines.
http://www.fimfiction.net/user/Treasure_Chest
Neshapotamus
Profile Blog Joined May 2006
United States163 Posts
Last Edited: 2011-09-06 07:16:37
September 06 2011 07:11 GMT
#1508
Hey EscPlan9,

Seems like you need parse an XML file (in your case a WSDL) and get relevant information from it.

I dont really understand what WIP is but I am assuming its your front end (GUI) which has some type of tree control which can parse an object.

Here is my plan on how I would tackle your situation:
http://schemas.xmlsoap.org/wsdl/ contains the XSD for any WSDL.
Save your xsd

Use visual studio tools to create a class out of the XSD as follows:
xsd.exe [fileName].xsd /c <--cmd line tool (this creates a C# class)

The xsd tool complained about "...", I needed to remove the "..." from the xsd to create the C# class

Add this class to your project.


Write this method as follows:
public object XmlToObject(Type type, string fileName)
{
XmlSerializer ser = new XmlSerializer(type);
FileStream myFileStream = new FileStream(fileName, FileMode.Open);
object obj = ser.Deserialize(myFileStream);
return obj;
}

Now you have your XML(WSDL) as a strong typed object instead of XML. You wont need to parse XML and make references to any xml methods.

You need to convert this object into a Model that you want to send out. I would create a model class and just grab the information you need from the deserialized object.

Have another methods that would create your model(deserialized object) with your tree structure which you would send to your front end.

PM me if this is confusing in any way or I didn't understand you correctly.

Frigo
Profile Joined August 2009
Hungary1023 Posts
September 06 2011 16:00 GMT
#1509
I've got a dilemma about a design choice in my pointer / reference wrapper, the insight of an outsider would be welcome.

Should I proxy operator == and != to the underlying class, just as I do in the case of other operators, or should I use them for pointer comparison instead? Or perhaps both, the latter for pointers, references, rvalue references, reference wrappers, and the former for everything else? Though it sounds kinda dangerous to have two different semantics for a single operator.

I already have an "is" member function for pointer comparison, but it is kinda ugly. For example
ref<int> x = 1;
ref<int> xcopy = x;
ref<int> y = 2;
cout << x.is(xcopy) << endl;
cout << x.is(y) << endl;
cout << x.is(null) << endl;


Perhaps I could define an "is" macro with some trick so the following is possible
cout << x is xcopy << endl;
cout << x is y << endl;
cout << x is null << endl;


For reference, operator = is NOT proxied to the underlying class, it just copies the address where it can. If the user wants assignment he uses
ref<SomeClass> x = new SomeClass(...);
ref<SomeClass> y = new SomeClass(...);
x.get() = y.get();

http://www.fimfiction.net/user/Treasure_Chest
mmp
Profile Blog Joined April 2009
United States2130 Posts
Last Edited: 2011-09-07 15:22:02
September 07 2011 13:53 GMT
#1510
Challenge: Write a function A in your language of choice that takes an object argument O and adds a new function B to O defined as follows: given a function argument C, B sets every other function D in O (exclude B) in the object equal to the given function C applied to the original function D (the return value of C(D) is a function, of course).

Solution (javascript):
+ Show Spoiler +

A = function(O) {
var modified = new Array();
for (var D in O) {
if (!Object.isFunction(O[D])) continue;
modified.push(D);
};
O.B = function(C) {
modified.each(function(D){
O[D] = C(O[D]);
});
return O;
};
return O;
}


I wrote something like this today as part of a functional modifier stack. So you declare A(O) to make an O with extensible methods. You can repeatedly stack functions by repeatedly calling O.B(C) to convert every D into C(D), C(C(D)), C(C(C(D))).... Here is a video of what a modifier stack looks like in Blender to get an idea of how useful this can be.
I (λ (foo) (and (<3 foo) ( T_T foo) (RAGE foo) )) Starcraft
Frigo
Profile Joined August 2009
Hungary1023 Posts
Last Edited: 2011-09-07 16:56:14
September 07 2011 14:08 GMT
#1511
So you are essentially doing an O.D ∘ C composition for every D method of O, where C is a function.

That is not possible in C++ due to lack of type inspection. Even with a wrapper class like mine, you can not proxy methods with arbitrary name, so composition of all methods is not possible. Especially not dynamically.

But I believe you can make a class template A that in its constructor accepts o and c objects (of which are instances of template parameters O and C, an object and a functor respectively), and proxies all operators and a given set of methods of O that are known beforehand. Still no dynamically though.

Edit:

Yup, it is possible statically for a limited set of methods and operators, see this example for operator ():

#include <iostream>
#include <functional>
#include <utility>

using namespace std;

template <class O, class C>
class A
{

public:

A (O& o2, C& c2) :
o (o2),
c (c2)
{}

template <class... Args>
decltype(std::declval<O&&>()(std::declval<C&&>()(std::declval<Args&&>()...))) operator () (Args&&... args)
{
return o(c(std::forward<Args&&>(args)...));
}

protected:

O& o;
C& c;

};



class O
{

public:

int operator () (int x)
{
return 2 * x;
}

};

class C
{

public:

int operator () (int x)
{
return x + 1;
}

};


int main (int argc, char* argv[])
{
O o;
C c;
A<O, C> a(o, c);

cout << a(1) << endl;
cout << a(10) << endl;
}

http://www.fimfiction.net/user/Treasure_Chest
mmp
Profile Blog Joined April 2009
United States2130 Posts
September 07 2011 15:31 GMT
#1512
Impressive, Frigo. I was hoping someone would post a C/C++ solution.
I (λ (foo) (and (<3 foo) ( T_T foo) (RAGE foo) )) Starcraft
icystorage
Profile Blog Joined November 2008
Jollibee19343 Posts
September 08 2011 12:57 GMT
#1513
i would like to thank the people who helped my on my last problem, yes it was working properly, my bad D:

i have another problem :< im stuck and i hope you guys can help
it compiles correctly but gives an error when i use it


> myprod n m = if m == 0 then 0 else (myprod n (m - 1)) + n

> myprod2 n m = if n == 1 then m else if n mod 2 == 1 then (myprod (n div 2) (m + m)) + m else (myprod (n div 2) (m + m))



this is a multiplication function.
myprod is my old fcn, its very slow so i tried improving it by using binary multiplication.

myprod2 is what i have come up but it returns an error even though it compiles properly, the error is

no instance for (num ((a0->a0->a0->a10->a20)) arising from the literal '5'
possible fix: add an instance declaration for (num ((a0->a0->a0->a10->a20))

and my problem is i dont know how to fix it =/
LiquidDota StaffAre you ready for a Miracle-? We are! The International 2017 Champions!
Kambing
Profile Joined May 2010
United States1176 Posts
Last Edited: 2011-09-08 15:20:11
September 08 2011 14:39 GMT
#1514
On September 08 2011 21:57 icystorage wrote:
i would like to thank the people who helped my on my last problem, yes it was working properly, my bad D:

i have another problem :< im stuck and i hope you guys can help
it compiles correctly but gives an error when i use it


> myprod n m = if m == 0 then 0 else (myprod n (m - 1)) + n

> myprod2 n m = if n == 1 then m else if n mod 2 == 1 then (myprod (n div 2) (m + m)) + m else (myprod (n div 2) (m + m))



this is a multiplication function.
myprod is my old fcn, its very slow so i tried improving it by using binary multiplication.

myprod2 is what i have come up but it returns an error even though it compiles properly, the error is

no instance for (num ((a0->a0->a0->a10->a20)) arising from the literal '5'
possible fix: add an instance declaration for (num ((a0->a0->a0->a10->a20))

and my problem is i dont know how to fix it =/


That's a compiler error actually. The problem is that when you use standard function names as infix operators, you need to encase them in backquotes, e.g., n `div` 2 is equivalent to div 2 n. Writing 1 div 2 is in effect saying "apply the div function (of type Integral a => a -> a -> a) to the constant 1 (of type Num a => a) and then take the result and apply the constant 2". Clearly 1 is not a function so the whole thing fails to type check.

EDIT: because of typeclasses, Haskell can give 1 div 2 a type

1 div 2 :: (Num a1, Num ((a -> a -> a) -> a1 -> t), Integral a) => t


Because it tries to unify the type of 1 with a function type that can take the div function as an argument. However, it fails when the typechecker tries to find an instantiation of the type variable a that satisfies the constraint. Hence the nasty compiler error that you see.
FranzP
Profile Joined November 2010
France270 Posts
Last Edited: 2011-09-08 15:13:08
September 08 2011 14:53 GMT
#1515
@Frigo I'm working with java so there is this kind of design i.e. == compares ref and .equals(x) method compares content.

What I don't like with this design is that I usually use object comparison more often than ref comparison. And I feel like the equals method clutters my code.

It's just about taste but if I were you I would use == to compare the referenced object and another method to compare reference. That's just my feelings using == and .equals()
"Cyberhacking is kind of like masturbation I guess, all countries do it but nobody actually talks about it. China just was accidentally doing it with the door wide open." Newbistic
Nisani201
Profile Joined September 2010
United States1400 Posts
September 08 2011 15:17 GMT
#1516
w3schools should not be included in the OP; read this for more info.
Enjoy your day.
Deleted User 101379
Profile Blog Joined August 2010
4849 Posts
September 08 2011 15:23 GMT
#1517
On September 08 2011 23:53 FranzP wrote:
@Frigo I'm working with java so there is this kind of design i.e. == compares ref and .equals(x) method compares content.

What I don't like with this design is that I usually use object comparison more often than ref comparison. And I feel like the equals method clutters my code.

It's just about taste but if I were you I would use == to compare the referenced object and another method to compare reference. That's just my feelings using == and .equals()


.equals() also adds some problems to the language like x.equals(y); that throws an exception if x is null, == doesn't have that problem. That leads to wierd stuff like "somestring".equals(x); which is... not quite logical or intuitive.
Kambing
Profile Joined May 2010
United States1176 Posts
September 08 2011 16:36 GMT
#1518
On September 09 2011 00:23 Morfildur wrote:
Show nested quote +
On September 08 2011 23:53 FranzP wrote:
@Frigo I'm working with java so there is this kind of design i.e. == compares ref and .equals(x) method compares content.

What I don't like with this design is that I usually use object comparison more often than ref comparison. And I feel like the equals method clutters my code.

It's just about taste but if I were you I would use == to compare the referenced object and another method to compare reference. That's just my feelings using == and .equals()


.equals() also adds some problems to the language like x.equals(y); that throws an exception if x is null, == doesn't have that problem. That leads to wierd stuff like "somestring".equals(x); which is... not quite logical or intuitive.


.equals itself is a nasty corner of the language due to the difference between primitive (value) and reference types. However, being able to call methods on any object, i.e., "hello".equals(x), should be expected in an object-oriented language where "everything is an object". It ought to be considered weird that you aren't able to call methods on primitive data (in Java at least, C# automatically boxes primitives so that you can do this --- at the cost of the actual boxing operation).
icystorage
Profile Blog Joined November 2008
Jollibee19343 Posts
September 08 2011 18:37 GMT
#1519
On September 08 2011 23:39 Kambing wrote:
Show nested quote +
On September 08 2011 21:57 icystorage wrote:
i would like to thank the people who helped my on my last problem, yes it was working properly, my bad D:

i have another problem :< im stuck and i hope you guys can help
it compiles correctly but gives an error when i use it


> myprod n m = if m == 0 then 0 else (myprod n (m - 1)) + n

> myprod2 n m = if n == 1 then m else if n mod 2 == 1 then (myprod (n div 2) (m + m)) + m else (myprod (n div 2) (m + m))



this is a multiplication function.
myprod is my old fcn, its very slow so i tried improving it by using binary multiplication.

myprod2 is what i have come up but it returns an error even though it compiles properly, the error is

no instance for (num ((a0->a0->a0->a10->a20)) arising from the literal '5'
possible fix: add an instance declaration for (num ((a0->a0->a0->a10->a20))

and my problem is i dont know how to fix it =/


That's a compiler error actually. The problem is that when you use standard function names as infix operators, you need to encase them in backquotes, e.g., n `div` 2 is equivalent to div 2 n. Writing 1 div 2 is in effect saying "apply the div function (of type Integral a => a -> a -> a) to the constant 1 (of type Num a => a) and then take the result and apply the constant 2". Clearly 1 is not a function so the whole thing fails to type check.

EDIT: because of typeclasses, Haskell can give 1 div 2 a type

1 div 2 :: (Num a1, Num ((a -> a -> a) -> a1 -> t), Integral a) => t


Because it tries to unify the type of 1 with a function type that can take the div function as an argument. However, it fails when the typechecker tries to find an instantiation of the type variable a that satisfies the constraint. Hence the nasty compiler error that you see.

*holds hand* thank you my friend... thank you... how could i be so stupid ._.
LiquidDota StaffAre you ready for a Miracle-? We are! The International 2017 Champions!
Frigo
Profile Joined August 2009
Hungary1023 Posts
September 08 2011 19:20 GMT
#1520
On September 08 2011 23:53 FranzP wrote:
@Frigo I'm working with java so there is this kind of design i.e. == compares ref and .equals(x) method compares content.

What I don't like with this design is that I usually use object comparison more often than ref comparison. And I feel like the equals method clutters my code.

It's just about taste but if I were you I would use == to compare the referenced object and another method to compare reference. That's just my feelings using == and .equals()


Thank you for your feedback. I asked my friend as well and concluded that indeed this is the correct approach.

Object comparison is done with == and !=, pointer comparison is done with an "is" macro that is defined as:
#define is .getPointer() ==


It seems to be working pretty well, it handles pointer comparison between reference wrappers as well, due to implicit conversion to pointer.
http://www.fimfiction.net/user/Treasure_Chest
Prev 1 74 75 76 77 78 1031 Next
Please log in or register to reply.
Live Events Refresh
WardiTV European League
12:00
Swiss Groups Day 2
WardiTV744
TKL 396
Liquipedia
FEL
12:00
Cracov 2025: Qualifier #2
IndyStarCraft 310
CranKy Ducklings93
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
TKL 396
IndyStarCraft 310
Rex 119
MindelVK 39
StarCraft: Brood War
Sea 11032
Calm 9514
Rain 7180
Bisu 2849
Horang2 2292
Hyuk 1365
Jaedong 1317
Shuttle 516
Rush 430
EffOrt 300
[ Show more ]
Stork 282
Leta 270
Last 240
PianO 210
Mini 206
ToSsGirL 156
Hyun 140
ZerO 95
Movie 79
hero 55
TY 53
Sea.KH 41
JYJ40
Killer 35
JulyZerg 29
ajuk12(nOOB) 22
HiyA 20
GoRush 19
Free 19
zelot 19
Terrorterran 18
Sacsri 17
Barracks 16
Icarus 6
ivOry 2
Stormgate
NightEnD21
Dota 2
qojqva3130
XcaliburYe514
canceldota91
League of Legends
singsing2904
Counter-Strike
x6flipin739
zeus453
Heroes of the Storm
Khaldor354
Other Games
Gorgc2822
B2W.Neo1336
DeMusliM533
Happy390
Fuzer 389
crisheroes359
Pyrionflax337
XaKoH 263
Hui .235
RotterdaM143
ArmadaUGS66
KnowMe53
ZerO(Twitch)18
Organizations
StarCraft: Brood War
CasterMuse 25
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 14 non-featured ]
StarCraft 2
• StrangeGG 38
• iHatsuTV 6
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• WagamamaTV771
• Ler42
Upcoming Events
BSL: ProLeague
5h 12m
Dewalt vs Bonyth
Replay Cast
1d 11h
Sparkling Tuna Cup
1d 21h
WardiTV European League
2 days
The PondCast
2 days
Replay Cast
3 days
RSL Revival
3 days
ByuN vs SHIN
Clem vs Reynor
Replay Cast
4 days
RSL Revival
4 days
Classic vs Cure
FEL
5 days
[ Show More ]
RSL Revival
5 days
FEL
5 days
FEL
6 days
Sparkling Tuna Cup
6 days
RSL Revival
6 days
Liquipedia Results

Completed

BSL 2v2 Season 3
HSC XXVII
Heroes 10 EU

Ongoing

JPL Season 2
BSL Season 20
Acropolis #3
KCM Race Survival 2025 Season 2
CSL 17: 2025 SUMMER
Copa Latinoamericana 4
Jiahua Invitational
Championship of Russia 2025
RSL Revival: Season 1
Murky Cup #2
BLAST.tv Austin Major 2025
ESL Impact League Season 7
IEM Dallas 2025
PGL Astana 2025
Asian Champions League '25
BLAST Rivals Spring 2025
MESA Nomadic Masters
CCT Season 2 Global Finals
IEM Melbourne 2025

Upcoming

2025 ACS Season 2: Qualifier
CSLPRO Last Chance 2025
2025 ACS Season 2
CSLPRO Chat StarLAN 3
K-Championship
uThermal 2v2 Main Event
SEL Season 2 Championship
FEL Cracov 2025
Esports World Cup 2025
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.