|
1. The lounge is for the CodeProject community to discuss things of interest to the community, and as a place for the whole community to participate. It is, first and foremost, a respectful meeting and discussion area for those wishing to discuss the life of a Software developer.
The #1 rule is: Be respectful of others, of the site, and of the community as a whole.
2. Technical discussions are welcome, but if you need specific programming question answered please use Quick Answers[^], or to discussion your programming problem in depth use the programming forums[^]. We encourage technical discussion, but this is a general discussion forum, not a programming Q&A forum. Posts will be moved or deleted if they fit better elsewhere.
3. No sys-admin, networking, "how do I setup XYZ" questions. For those use the SysAdmin[^] or Hardware and Devices[^] forums.
4. No politics (including enviro-politics[^]), no sex, no religion. This is a community for software development. There are plenty of other sites that are far more appropriate for these discussions.
5. Nothing Not Safe For Work, nothing you would not want your wife/husband, your girlfriend/boyfriend, your mother or your kid sister seeing on your screen.
6. Any personal attacks, any spam, any advertising, any trolling, or any abuse of the rules will result in your account being removed.
7. Not everyone's first language is English. Be understanding.
Please respect the community and respect each other. We are of many cultures so remember that. Don't assume others understand you are joking, don't belittle anyone for taking offense or being thin skinned.
We are a community for software developers. Leave the egos at the door.
cheers,
Chris Maunder
The Code Project | Co-founder
Microsoft C++ MVP
modified 16-Sep-19 9:31am.
|
|
|
|
|
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:
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
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.
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.
|
|
|
|
|
And now there is in the newer version:
if (obj is string str)
{
...
} Which - now I've got used to it - I like; it's a good way to limit the scope.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
It parses fast enough, but it takes so long to resolve what it parsed though. I need to figure out how to optimize this thing.
Still, the parser is getting more and more stable. It already parses better than that ANTLR C#6 grammar did.
Technically, it can usually convert to VB without going through the resolution process, but it's kind of a hack. It just so happens that in VB there's no difference in syntax between a delegate invocation and a method call, nor a field access and a property access so it happens to work, but it's not proper to resolve method invocations as delegate invocations and all member access as field access which is what the parser has to do, since it doesn't have type info.
Overall I'm happy with the project but I need to figure on something to make it more speedy so it will be generally useful.
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.
|
|
|
|
|
Awesome work (and best of luck with the optimising)
cheers
Chris Maunder
|
|
|
|
|
Thanks. The articles bombed so far but I think that's either because it's so preliminary, or people don't understand it, or nobody has a use for it. Or a combination of those things. Still, *I* have a couple of uses for it and I understand it so that's a start.
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.
|
|
|
|
|
There are no lines.
Something I keep wondering about your Slang system is whether or not it can be used to implement a language extension similar to Oracle's PRO*C or Microsoft's ESQL -- SQL statements embedded in C programs (or C# now I suppose).
|
|
|
|
|
LINQ already kind of provides that, but yes. You can use this as a starting point to implement a Domain Specific Language.
If I was real clever I might make it so you could extend the language through the language itself. Adding keywords and such but that's out of the scope of this for now.
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.
|
|
|
|
|
honey the codewitch wrote: LINQ already kind of provides that
It does no such thing.
|
|
|
|
|
Then i misunderstood what you meant. LINQ provides SQL like syntax over disparate datasources, including databases.
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.
|
|
|
|
|
|
Then I must be using a magic feature of an as of yet unheard of version of C# with magical embedded sql like syntax that nobody else has access to.
Gosh thanks microsoft. Boy, I feel speshul.
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.
|
|
|
|
|
Unstoppable force, may I introduce immovable object.
ESQL and Pro*C aren't "SQL Like".
They are embedded SQL.
|
|
|
|
|
Wow... are you trying to impress us?
well.... it might work!
you need to make an article with some cool nifty example! :P
|
|
|
|
|
The 2 articles i posted on it so far bombed LOL
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.
|
|
|
|
|
mm... I am not sure what you mean by "bombed"
is it this and that one?
I can only see 4 and 2 votes so far!
Just quickly read that at work just now!
Mm.... this is cool and obviously quite an achievement
However I am not sure where I could reuse that myself..
I'll have to think about it again if / when I need code generation....
|
|
|
|
|
It *is* pretty specialized. I do a lot of codegen so obv to me it's useful but i don't think it will ever have a wide audience.
Where it's super useful to is once it's shored up enough I can use it in my parsers for code inside the grammar. If you write it in Slang it will render out in whatever so it doesn't tie the grammar to a particular output language. Downside is the language in the grammar must be Slang.
Right now I've also added an Evaluate() method to CodeDomResolver so it can evaluate expressions, call methods and such at runtime. If I did full evaluation i could do runtime grammars without codegen but it would be S-L-O-W.
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.
|
|
|
|
|
Neal.fun[^]
Frank Wilhoit: “Conservatism consists of exactly one proposition …There must be in-groups whom the law protects but does not bind, alongside out-groups whom the law binds but does not protect.”
We never have had a president* so completely deserving of scorn and yet so small in the office that it almost seems a waste of time and energy to summon the requisite contempt
|
|
|
|
|
Emperor Penguins can dive to 528m?!
Whoa.
And an elephant seal to 2.4km.
Amazing
cheers
Chris Maunder
|
|
|
|
|
where is spongebob squarepants? 
|
|
|
|
|
There's some creature living more than 10KMs under the ocean.
When humans set their deep sea diving record, the Hadal Amphipod be like, "bitch please". 
|
|
|
|
|
I sit near her computer and lately it started to emit a gawdawful hum that slowly gets worse with each passing week. The machine is getting old - 7 years. So I checked and a new Dell for her is within reach financially. So I offered to get her a new desktop for Christmas.
"Why?" She asked.
"That hum is getting worse and it's making me nervous!" I replied.
"But the computer is not smoking yet - is it?" Was her reply.
So there is no need to replace the machine till it catches on fire?!
Her being very frugal is fantastic, but I wonder if I shouldn't just surprise her for Xmas? 
|
|
|
|
|
Cp-Coder wrote: So there is no need to replace the machine till it catches on fire?! Some people do not replace stuff until it breaks completely. I have socks that are over 25 years in age; they still do what they're supposed to do, and they perform as well as one can expect from socks.
My previous desktop lasted 6 years; I hardly call that old, there's older machines for "sale" in the mall.
She would still like you if you buy her a new one though. Surprise her for New Year, when she doesn't expect it. And prepare for a lecture on how the old machine was fine and still perfect
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
I wonder what the average age is for computers that belong to Code Project members? Maybe this is a good question for a future survey?
|
|
|
|
|
..and origin; my bet is people from the Netherlands or the former DDR will be more likely to keep using their machines (and pants) until they break.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|