5 ms·
Here is a snippet of code from the Verse screencast (linked elsewhere in thread) that demonstrates a new idea (or at least a new variant) with new power. Basica
by mcbrit 4y ago
Here is a snippet of code from the Verse screencast (linked elsewhere in thread) that demonstrates a new idea (or at least a new variant) with new power. Basically, you set up a bunch of constraints for the do clause, and if any of the constraints fail for any reason (including array index of out bounds), then the do clause is simply not invoked for that parameter space.
It's pretty elegant.
for:
Y->CellRow:Cells
X->Cell:CellRow
AdjacentX:=X-1..X+1
AdjacentY:=Y-1..Y+1
AdjacentCell := Cells[AdjacentY][AdjacentX]
Cell<>AdjacentCell
AdjacentCell.Mined?
do:
set Cell.AdjacentMines += 1
- mikro2nd 4y agoThanks for posting this. When I looked at the linked page, my immediate complaint was, "Just show me a small example!" I don't really have the time or inclination to dig into all those links to see the syntax for code-blocks, comments (for gods' sake!) or expressions, none of which will give me a feel for the language anyway. (My interest is very casual, prompted only by my interest in improving software tooling (languages particularly) and it's a fairly low priority for me in the first place.) So mcbrit's quick snippet to the rescue! :D eta: I do wish programming language pages would all just put a small code sample right there on their landing page, at least as a supplement to whatever else they want to say. Mostly it's going to be experienced developers who look, and we don't want/need a lot of fluff; we're reasonably likely to fairly quickly grok most of what's interesting about a language from a well-crafted example, and that's more likely than anything else to prompt us to dig deeper if it tickles something inside us.
- smcl 4y ago> I do wish programming language pages would all just put a small code sample right there on their landing page Seconded. As someone who doesn't work with Fortnite/UE5 development I suspect this page isn't really meant for me. But I would at least have assumed they'd want to have a few little standalone examples front-and-centre to entice any potential users
- antifa 4y ago> I do wish programming language pages would all just put a small code sample right there on their landing page Also make sure your learnxiny page is up to date and appealing. GDScript (godot) has one: https://learnxinyminutes.com/docs/gdscript/ https://learnxinyminutes.com/docs/gdscript/ Offtopic examples: Nim: https://learnxinyminutes.com/docs/nim/ https://learnxinyminutes.com/docs/nim/ Crystal: https://learnxinyminutes.com/docs/crystal/ https://learnxinyminutes.com/docs/crystal/ After reading those, how can you say no to nim or crystal? I didn't even understand the Verse sample, I'd need to see the equivalent c++ (or other common language) to really get what made it appealing. Maybe also more explanation on why. A good learnxiny page might have done that for me.
- randomifcpfan 4y agoNote the current Verse style guideline is to capitalize variables rather than types. Seems pointlessly contrary to established practice. Makes the code read like the author is shouting.
- 4ad 4y agoLet me make a prediction: this is because types in Verse will be just (failable?) functions that validate values. Notice that types are lowercase. I said failable above, but they might be some other kind of functions. They have a total effect type (functions that are guaranteed to terminate), which could be safely called by the type checker.
- DecoPerson 4y agoThe target audience is less-tech-savvy game devs (paper designers, artists, narrative designers, fx, sound, etc). They don’t have as much familiarity with camelCase or snake_case as us programmers do. CapitalCase is friendlier to a wider audience.
- canadianfella 4y ago[dead]
- kelsolaar 4y agoThis is also consistent with the typical naming convention of properties in Unreal Engine.
- antifa 4y ago> CapitalCase is friendlier to a wider audience. Only if the variable is a proper noun... otherwise it's pointlessly contrarian.
- deleted 4y ago[deleted]
- _448 4y agoThis is like the C++ Concepts idea except for the control statements. The C++ Concepts work with the same idea except it is at compile-time and applies to the whole function or a type/class.
- srgpqt 4y agoElixir has this too.