Click here to Skip to main content
15,892,072 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Ccc - you win! Pin
OriginalGriff9-Dec-19 1:23
mveOriginalGriff9-Dec-19 1:23 
GeneralRe: Ccc - you win! Pin
The pompey9-Dec-19 2:25
The pompey9-Dec-19 2:25 
JokeRe: Ccc - you win! Pin
Daniel Pfeffer9-Dec-19 2:40
professionalDaniel Pfeffer9-Dec-19 2:40 
GeneralRe: Ccc - you win! Pin
Sander Rossel9-Dec-19 2:51
professionalSander Rossel9-Dec-19 2:51 
GeneralRe: Ccc - you win! Pin
kalberts10-Dec-19 6:27
kalberts10-Dec-19 6:27 
GeneralRe: Ccc - you win! Pin
Sander Rossel11-Dec-19 2:03
professionalSander Rossel11-Dec-19 2:03 
GeneralRe: Ccc - you win! Pin
musefan9-Dec-19 2:55
musefan9-Dec-19 2:55 
GeneralI never knew I'd miss an operator I hate so much Pin
honey the codewitch8-Dec-19 19:57
mvahoney the codewitch8-Dec-19 19:57 
So C# has "as" which is like an attempted cast. If the cast fails no error is thrown, but the target value is set to null, such like:
C#
string str = obj as string;


A) It's faster than a cast
B) it lets you do two things in one - cast an object and check the object's type.

So it's more efficient than a cast, in .NET

However, it leads to code patterns like

C#
var cc = obj as CodeComment;
if (null != cc)
{
	_VisitComment(cc,args, action);
	return;
}
var ccu = obj as CodeCompileUnit;
if (null != ccu)
{
	_VisitCompileUnit(ccu,args, action);
	return;
}
var cd = obj as CodeDirective;
if (null != ccu)
{
	_VisitDirective(cd, args, action);
	return;
}


C#8? introduced a switch style pattern for this but it's still ugly.

That's why I don't like it.

However,in Slang it is not supported, nor can it be, because the only way to emulate that particular operator (which resolves to a specific IL instruction) is using minor reflection (Type.IsAssignableFrom()), which is unacceptable here.

And so a lot of my code simply won't parse. Dead | X|

Curse the CodeDOM for being so sparse. I really wish it supported more operators. There are no unary operators, no try-cast (like above) and most of the assign operators are gone as are maybe half the binary expressions available in most languages. It's kind of a bad joke but there's nothing to be done about it now. Microsoft made the standard. Others adhere to it, broken as it is.

I mean, the CodeDOM is useful but it's bloody limited. I wish Roslyn had pluggable support for additional compilers like F# but as far as I know it's strictly C# and VB

Still, it might be useful eventually to make a Roslyn version of slang once it too can run on a phone. But for now I'm stuck with the stodgy old CodeDOM. Though working with Roslyn would mean most of what my code does wouldn't be necessary in the first place.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.

GeneralRe: I never knew I'd miss an operator I hate so much Pin
OriginalGriff8-Dec-19 20:33
mveOriginalGriff8-Dec-19 20:33 
GeneralRe: I never knew I'd miss an operator I hate so much Pin
Super Lloyd8-Dec-19 23:30
Super Lloyd8-Dec-19 23:30 
GeneralRe: I never knew I'd miss an operator I hate so much Pin
honey the codewitch8-Dec-19 23:32
mvahoney the codewitch8-Dec-19 23:32 
GeneralRe: I never knew I'd miss an operator I hate so much Pin
OriginalGriff8-Dec-19 23:56
mveOriginalGriff8-Dec-19 23:56 
GeneralRe: I never knew I'd miss an operator I hate so much Pin
harold aptroot9-Dec-19 0:42
harold aptroot9-Dec-19 0:42 
GeneralRe: I never knew I'd miss an operator I hate so much Pin
honey the codewitch9-Dec-19 2:51
mvahoney the codewitch9-Dec-19 2:51 
GeneralRe: I never knew I'd miss an operator I hate so much Pin
PIEBALDconsult9-Dec-19 8:26
mvePIEBALDconsult9-Dec-19 8:26 
GeneralRe: I never knew I'd miss an operator I hate so much Pin
OriginalGriff9-Dec-19 9:16
mveOriginalGriff9-Dec-19 9:16 
GeneralRe: I never knew I'd miss an operator I hate so much Pin
PIEBALDconsult9-Dec-19 9:49
mvePIEBALDconsult9-Dec-19 9:49 
GeneralRe: I never knew I'd miss an operator I hate so much Pin
OriginalGriff9-Dec-19 21:14
mveOriginalGriff9-Dec-19 21:14 
GeneralRe: I never knew I'd miss an operator I hate so much Pin
PIEBALDconsult10-Dec-19 3:11
mvePIEBALDconsult10-Dec-19 3:11 
GeneralRe: I never knew I'd miss an operator I hate so much Pin
Super Lloyd8-Dec-19 23:29
Super Lloyd8-Dec-19 23:29 
GeneralRe: I never knew I'd miss an operator I hate so much Pin
honey the codewitch8-Dec-19 23:30
mvahoney the codewitch8-Dec-19 23:30 
GeneralRe: I never knew I'd miss an operator I hate so much Pin
Greg Utas9-Dec-19 1:11
professionalGreg Utas9-Dec-19 1:11 
GeneralRe: I never knew I'd miss an operator I hate so much Pin
honey the codewitch9-Dec-19 2:54
mvahoney the codewitch9-Dec-19 2:54 
GeneralRe: I never knew I'd miss an operator I hate so much Pin
PIEBALDconsult9-Dec-19 8:10
mvePIEBALDconsult9-Dec-19 8:10 
GeneralYAY! Slang parsed 8000+ lines of C# code. Pin
honey the codewitch8-Dec-19 16:29
mvahoney the codewitch8-Dec-19 16:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.