Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Odd symbol comparison behaviour #6

Closed
2bt opened this issue Mar 2, 2015 · 5 comments
Closed

Odd symbol comparison behaviour #6

2bt opened this issue Mar 2, 2015 · 5 comments
Assignees

Comments

@2bt
Copy link

2bt commented Mar 2, 2015

I've come across this behaviour which wasn't quite what I expected. Is it an actual bug or am I missing something?

Console.WriteLine("(eq? 'A 'A)".Eval());                                        // True
Console.WriteLine("(eq? 'A {0})".Eval("'A".Eval()));                            // True
Console.WriteLine("(eq? 'A {0})".Eval((SymbolId) "'A".Eval()));                 // False
Console.WriteLine("(eq? 'A {0})".Eval((SymbolId) "A"));                         // False
Console.WriteLine("(eq? {0} {1})".Eval((SymbolId) "A", (SymbolId) "A"));        // False
Console.WriteLine("eq?".Eval<Callable>().Call((SymbolId) "A", (SymbolId) "A")); // False
@leppie
Copy link
Member

leppie commented Mar 3, 2015

Thanks! Will check it out.

@leppie
Copy link
Member

leppie commented Mar 3, 2015

This is caused by boxing behavior in C#. All symbols in IronScheme are interned, hence a reference comparison works.

The best way to do this specific case is to emulate what the compiler does and use SymbolTable.StringToObject(string) or use SymbolTable.Intern(SymbolId).

It might be a good idea though for me to check the parameters for SymbolId type and call that Intern for Eval. I will play with the idea.

@leppie
Copy link
Member

leppie commented Mar 3, 2015

Good news (and 1 bad).

I can get all of them to return true except for the last.

I suggest you use the workaround with SymbolTable there.

Will make the change tonight and commit and rebuild.

@leppie leppie self-assigned this Mar 3, 2015
@2bt
Copy link
Author

2bt commented Mar 3, 2015

Thanks for the fast response and your suggested workaround.

@leppie
Copy link
Member

leppie commented Mar 3, 2015

Fixed in commit 2716cab

@leppie leppie closed this as completed Mar 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants