Extending OpenSCAD from assembler to C or Perlish language and adding standard library

classic Classic list List threaded Threaded
110 messages Options
123456
Reply | Threaded
Open this post in threaded view
|

Re: Extending OpenSCAD from assembler to C or Perlish language and adding standard library

nophead
I have a tube in my library but I can't think a use for a hollow cube. Any boxes I make have rounded corners and an open face.

On Mon, 16 Sep 2019 at 23:49, lar3ry <[hidden email]> wrote:
Robin2 wrote
> I must say that I disagree with the proposed "shorthand". IMHO the single
> biggest flaw in the C/C++ programming language is the unwillingness of the
> original designers to use meaningful names for things. The multiple use of
> the asterisk is particularly infuriating.
>
> Regardless of what programming language is used,  single character
> variable
> names such as T are a nightmare when you want to find all the instances of
> a
> variable.

I agree wholeheartedly. I have no trouble remembering shorthand substitutes
for commonly used keywords, but ONLY if I defined them myself. As you say,
single character shortcuts are not only bad for searching, but also for
parsing, should one want to generate a translation program that will take an
OpenSCAD file with shortcuts and pretty-print the full OpenSCAD code. I love
the idea of xtran(n), ytran(n), ztran(n), and so on.

This discussion has been a real eye-opener for me.  I will definitely be
generating a library file that includes many of the ideas presented here...
shortcuts, tubes, hollow cubes, and so on, and will attempt to write a
program that will translate all the shortcuts at the very least, back to
native OpenSCAD.




--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Extending OpenSCAD from assembler to C or Perlish language and adding standard library

adrianv
In reply to this post by sampo-openscad19
sampo-openscad19 wrote
> 2. The syntax and keywords, originally intended for communication, should
>    be abbreviated as to not burden model programmer excessively. In
> essence,
>    the ubiquitous "translate()" should somehow be abbreviated (our modest
>    suggestion is T() as already possible through module() interface, but
>    not formalized or suggested anywhere in the documentation).

As with others I agree this is a terrible idea for the same reasons.   But
some abbreviations can be handy.  BOSL provides a bunch of shortcuts like
this.    

One thing that I find really puzzling is the opposition to standardization
that I see.   One poster said abbreviations are only ok if he made them up
himself.  I mean, yeah, I understand it might be a little more work---maybe
it takes a week---to get used to someone else's abbreviations.  I have a
hard time understanding how people wouldn't learn them from regular use.
(If it's so hard...how did they learn to use the native OpenSCAD commands in
the first place?)  It's really beneficial to have a more unified set of
extensions rather than everybody makes up their own abbreviations.  It means
posted code examples are more comprehensible, for example.  In general it
makes code more sharable.    

One person suggested that we need to understand who the users are.  If the
users are indeed people with only a passing interest in modeling who want to
make 3 throw-away models per year, then there's no reason to do any further
development.  Why bother?  

Maybe my frustration with the limits of OpenSCAD as it stands stem from
being a user with a deeper interest in real modeling.  Should I be using
some other tool?  


> 3. There should be a standard library of commonly needed objects, like
>    parametrized ergonometric human model or (metric) screws and nuts.
>
> I am willing to program the features proposed below, but before I start
> I want to know if they would be likely to be integrated to mainline
> OpenSCAD. Or if I am reinventing a wheel. If my proposals already
> exist, I would like to know about them and that documentation be
> updated so that people like me would find them easily.

Based on what I've seen I can say that (1) features you program are
extremely unlikely to be integrated into OpenSCAD in any official way and
(2) you would almost certainly be reinventing the wheel.   Almost everything
you suggest that can be done in libraries has already been done by somebody.  
The BOSL and BOSL2 libraries support almost everything you propose.  (Note
BOSL is the old, stable library and BOSL2 is new, but currently unstable
version in development.)  

See here for documentation:  https://github.com/revarbat/BOSL2/wiki   Most
of what you asked for is in shapes or transformations.   I would suggest
that you might take a look at BOSL2 and other libraries and see what
features are lacking from them before you start work on your own extensions.  

On the matter of redefining primitives like cube(), it is already possible
to do this.  You just can't ever use the old cube() afterwards.  If you
really want to prevent users from making their own nonstandard versions
where cube() makes a sphere or something, you would need to ban redefinition
of primitives.  Allowing users to call the original cube() and know for sure
it's the original cube() should make things less confusing, not more so.





--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Extending OpenSCAD from assembler to C or Perlish language and adding standard library

lar3ry
In reply to this post by nophead
nophead wrote
> I have a tube in my library but I can't think a use for a hollow cube. Any
> boxes I make have rounded corners and an open face.

I was thinking of something that floats, but in retrospect, I guess the
slicer will take care of making it hollow.





--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Extending OpenSCAD from assembler to C or Perlish language and adding standard library

MichaelAtOz
Administrator
Non-FDM printers frequently want hollow shapes, with escape holes, to save on raw materials.

> -----Original Message-----
> From: Discuss [mailto:[hidden email]] On Behalf Of lar3ry
> Sent: Tue, 17 Sep 2019 13:09
> To: [hidden email]
> Subject: Re: [OpenSCAD] Extending OpenSCAD from assembler to C or Perlish language and adding
> standard library
>
> nophead wrote
> > I have a tube in my library but I can't think a use for a hollow cube. Any
> > boxes I make have rounded corners and an open face.
>
> I was thinking of something that floats, but in retrospect, I guess the
> slicer will take care of making it hollow.
>
>
>
>
>
> --
> Sent from: http://forum.openscad.org/
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


---
This email has been checked for viruses by AVG.
https://www.avg.com


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Admin - email* me if you need anything, or if I've done something stupid...
* click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work.
Obviously inclusion of works of previous authors is not included in the above.
rew
Reply | Threaded
Open this post in threaded view
|

Re: Extending OpenSCAD from assembler to C or Perlish language and adding standard library

rew
In reply to this post by doug.moen
On Mon, Sep 16, 2019 at 11:20:57AM -0400, Doug Moen wrote:
> OpenSCAD should add the flexibility to override built-in modules
> with new modules of the same name. You should be able to define a
> module called `cube`, and you should be able to reference the
> builtin module `cube` while defining the new version of `cube`.

This isn't too difficult to implement, I'd think.
Just rename the current cube () primitive to __cube () and provide
a default module cube () definition that calls __cube()...

        Roger.

--
** [hidden email] ** https://www.BitWizard.nl/ ** +31-15-2049110 **
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
The plan was simple, like my brother-in-law Phil. But unlike
Phil, this plan just might work.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Extending OpenSCAD from assembler to C or Perlish language and adding standard library

nophead
That doesn't work because the definition of cube overrides the original so that __cube() calls the new one and creates recursion.

On Tue, 17 Sep 2019 at 11:03, Rogier Wolff <[hidden email]> wrote:
On Mon, Sep 16, 2019 at 11:20:57AM -0400, Doug Moen wrote:
> OpenSCAD should add the flexibility to override built-in modules
> with new modules of the same name. You should be able to define a
> module called `cube`, and you should be able to reference the
> builtin module `cube` while defining the new version of `cube`.

This isn't too difficult to implement, I'd think.
Just rename the current cube () primitive to __cube () and provide
a default module cube () definition that calls __cube()...

        Roger.

--
** [hidden email] ** https://www.BitWizard.nl/ ** +31-15-2049110 **
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
The plan was simple, like my brother-in-law Phil. But unlike
Phil, this plan just might work.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
rew
Reply | Threaded
Open this post in threaded view
|

Re: Extending OpenSCAD from assembler to C or Perlish language and adding standard library

rew

What I meant was that the language can facilitate this option by
renaming the cube primitive to __cube(), and then having an
overridable module in place for the backwards compatiblity.

Now, the primitive may be able to do a few things that normal modules
cannot. For example, while it is easy to provide a centered=false
default on the module, you can just allways pass on centered=centered
on to the primitive. The "default" on the parameter will take care of
when the parameter is not specified. On the other hand I don't know
how to make the r=xx, d=yy behaviour on a cylinder. Does the primitive
"cheat" and do things that a user-written module cannot? Or are my
openscad skills simply not good enough. I don't know.

In any case, I was not suggesting that you could do this already by
redefining the prmiitve from your user-file.

        Roger.


On Tue, Sep 17, 2019 at 11:52:50AM +0100, nop head wrote:
> That doesn't work because the definition of cube overrides the original so
> that __cube() calls the new one and creates recursion.

> On Tue, 17 Sep 2019 at 11:03, Rogier Wolff <[hidden email]> wrote:
> > This isn't too difficult to implement, I'd think.
> > Just rename the current cube () primitive to __cube () and provide
> > a default module cube () definition that calls __cube()...


--
** [hidden email] ** https://www.BitWizard.nl/ ** +31-15-2049110 **
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
The plan was simple, like my brother-in-law Phil. But unlike
Phil, this plan just might work.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Extending OpenSCAD from assembler to C or Perlish language and adding standard library

nophead
Sorry, yes that would work.

Currently it is fairly easy to override the geometric primitives with something that produces the equivalent polyhedron or polygon without calling the original. I do that myself for sphere() to make one that includes the poles and equator.

To handle the multiple parameters I default the alternatives to undef and then use is_undef(), so I think one can do the same as the original but it would be quite a lot of code to do that and also check for errors, so speed might suffer.
module sphere(r = 1, d = undef) {                   //! Override ```sphere``` so that has vertices on all three axes. Has the advantage of giving correct dimensions when hulled
    R = is_undef(d) ? r : d / 2;
    rotate_extrude($fn = r2sides4n(R))
        rotate(-90)
            semi_circle(R);
}


On Tue, 17 Sep 2019 at 12:10, Rogier Wolff <[hidden email]> wrote:

What I meant was that the language can facilitate this option by
renaming the cube primitive to __cube(), and then having an
overridable module in place for the backwards compatiblity.

Now, the primitive may be able to do a few things that normal modules
cannot. For example, while it is easy to provide a centered=false
default on the module, you can just allways pass on centered=centered
on to the primitive. The "default" on the parameter will take care of
when the parameter is not specified. On the other hand I don't know
how to make the r=xx, d=yy behaviour on a cylinder. Does the primitive
"cheat" and do things that a user-written module cannot? Or are my
openscad skills simply not good enough. I don't know.

In any case, I was not suggesting that you could do this already by
redefining the prmiitve from your user-file.

        Roger.


On Tue, Sep 17, 2019 at 11:52:50AM +0100, nop head wrote:
> That doesn't work because the definition of cube overrides the original so
> that __cube() calls the new one and creates recursion.

> On Tue, 17 Sep 2019 at 11:03, Rogier Wolff <[hidden email]> wrote:
> > This isn't too difficult to implement, I'd think.
> > Just rename the current cube () primitive to __cube () and provide
> > a default module cube () definition that calls __cube()...


--
** [hidden email] ** https://www.BitWizard.nl/ ** +31-15-2049110 **
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
The plan was simple, like my brother-in-law Phil. But unlike
Phil, this plan just might work.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Extending OpenSCAD from assembler to C or Perlish language and adding standard library

Robin2
In reply to this post by rew
rew wrote
> This isn't too difficult to implement, I'd think.
> Just rename the current cube () primitive to __cube () and provide
> a default module cube () definition that calls __cube()...

Sorry, but I just can't see the point. What is so sacrosanct about the name
"cube" that someone can't work with a derived module called (say) "myCube"
without any need for developers to waste time changing the underlying code.


I get the impression that there is a large number of libraries with,
perhaps, a lot of close-but-not-perfect duplication amongst them. If that is
the problem then it should be fixed by some process of getting library
developers to work to a common standard, not by changing the core code.

...R



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Extending OpenSCAD from assembler to C or Perlish language and adding standard library

lostapathy
Amen.  The problem isn't that we need to extend the language, it's that we need to make library re-use (and subsequent improvement) productive like most every other language.

We would almost certainly converge on a certain set of really good libraries as a standard.  But trying to design them by committee into the language is how you get things like the Java versions of 20 years ago.


On 9/17/19 7:34 AM, Robin2 wrote:
Sorry, but I just can't see the point. What is so sacrosanct about the name
"cube" that someone can't work with a derived module called (say) "myCube"
without any need for developers to waste time changing the underlying code.


I get the impression that there is a large number of libraries with,
perhaps, a lot of close-but-not-perfect duplication amongst them. If that is
the problem then it should be fixed by some process of getting library
developers to work to a common standard, not by changing the core code.

...R



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Extending OpenSCAD from assembler to C or Perlish language and adding standard library

lar3ry
In reply to this post by nophead

> //! Override ```sphere``` so that has vertices on all three axes. Has the
> advantage of giving correct dimensions when hulled

I like the idea of this. Can you tell us the definition of the function: $fn
= r2sides4n(R))



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Extending OpenSCAD from assembler to C or Perlish language and adding standard library

nophead

On Tue, 17 Sep 2019 at 15:22, lar3ry <[hidden email]> wrote:

> //! Override ```sphere``` so that has vertices on all three axes. Has the
> advantage of giving correct dimensions when hulled

I like the idea of this. Can you tell us the definition of the function: $fn
= r2sides4n(R))



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Extending OpenSCAD from assembler to C or Perlish language and adding standard library

adrianv
In reply to this post by Robin2
Robin2 wrote
> Sorry, but I just can't see the point. What is so sacrosanct about the
> name
> "cube" that someone can't work with a derived module called (say) "myCube"
> without any need for developers to waste time changing the underlying
> code.

It seems to me that the main use of redefining modules is to extend
functionality somehow in a library, so the existing built-ins can behave
consistently in the context of the library with other functionality.  

The argument that the name "cube" is sacrosanct appears every day on this
forum:  many people seem to think that the burden of learning a new command
is quite overwhelming.  


> I get the impression that there is a large number of libraries with,
> perhaps, a lot of close-but-not-perfect duplication amongst them. If that
> is
> the problem then it should be fixed by some process of getting library
> developers to work to a common standard, not by changing the core code.

I would say that the situation is not so clear.  There do not appears to be
very many good libraries, well documented, that you can easily find.   I'm
not aware of a lot of good libraries that duplicate each other
substantially---maybe just BOSL with parts of dotSCAD.   But in my efforts
to hunt for libraries I saw a lot of functionality duplicated many times by
different people, maybe not put out as a library, but code that does the
same class of basic things, written by each individual to support other
purposes, because sharing libraries seems to be, for some reason, a very
difficult thing.  And if you write a library for your own use there's little
reason to bother documenting it.  

The lack of a really clear mechanism for distributing libraries has been one
problem.  It's pretty hard to find the various libraries that are scattered
on Thingiverse.  The general hostility of people on the forum to the use of
libraries is another factor that I think has discouraged the development of
a functional approach to libraries.  




--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Extending OpenSCAD from assembler to C or Perlish language and adding standard library

nophead
> many people seem to think that the burden of learning a new command is quite overwhelming.  

OpenScad is a tiny language and can be learned in its entirety in about a day, which I did many years ago. Libraries are much larger things to learn, and if I can write everything I use myself, why would I spend time learning somebody else's library?

I think the reason why they don't gain the same traction as conventional programming languages is most things are very easy to do in OpenSCAD with a few lines of code, whereas most libraries for other languages are a lot bigger and more complicated. 

On Wed, 18 Sep 2019 at 00:06, adrianv <[hidden email]> wrote:
Robin2 wrote
> Sorry, but I just can't see the point. What is so sacrosanct about the
> name
> "cube" that someone can't work with a derived module called (say) "myCube"
> without any need for developers to waste time changing the underlying
> code.

It seems to me that the main use of redefining modules is to extend
functionality somehow in a library, so the existing built-ins can behave
consistently in the context of the library with other functionality. 

The argument that the name "cube" is sacrosanct appears every day on this
forum:  many people seem to think that the burden of learning a new command
is quite overwhelming. 


> I get the impression that there is a large number of libraries with,
> perhaps, a lot of close-but-not-perfect duplication amongst them. If that
> is
> the problem then it should be fixed by some process of getting library
> developers to work to a common standard, not by changing the core code.

I would say that the situation is not so clear.  There do not appears to be
very many good libraries, well documented, that you can easily find.   I'm
not aware of a lot of good libraries that duplicate each other
substantially---maybe just BOSL with parts of dotSCAD.   But in my efforts
to hunt for libraries I saw a lot of functionality duplicated many times by
different people, maybe not put out as a library, but code that does the
same class of basic things, written by each individual to support other
purposes, because sharing libraries seems to be, for some reason, a very
difficult thing.  And if you write a library for your own use there's little
reason to bother documenting it.   

The lack of a really clear mechanism for distributing libraries has been one
problem.  It's pretty hard to find the various libraries that are scattered
on Thingiverse.  The general hostility of people on the forum to the use of
libraries is another factor that I think has discouraged the development of
a functional approach to libraries. 




--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Extending OpenSCAD from assembler to C or Perlish language and adding standard library

doug.moen
In reply to this post by adrianv
My original reason for wanting this feature is the Relativity library.
https://github.com/davidson16807/relativity.scad

Relativity extends the standard primitives `cube`, `sphere`, etc, with upward compatible new features: a system of property inheritance inspired by CSS.

But, because of the way OpenSCAD works, Relativity needs to invent new names for all of the primitives. So, `cube` becomes `box`, `cylinder` becomes `rod`, and so on.

So if you want to use Relativity in an existing project, you need to rewrite your code to replace `cube` with `box` and so on.

It would be better if Relativity could just add new features to `cube`, `sphere` and so on without requiring you to rewrite all of your code.

This would not be a problem in any modern programming language, because all modern languages support name spaces.

The underlying goal of many of the suggestions in my email was to provide tools for library writers, so that libraries can work better. And so that libraries can do things that currently require a change to the C++ core. We need a better library ecosystem. If you don't use libraries, then many of my suggested language changes won't help you.

Doug Moen.

On Tue, Sep 17, 2019, at 7:11 PM, adrianv wrote:

> Robin2 wrote
> > Sorry, but I just can't see the point. What is so sacrosanct about the
> > name
> > "cube" that someone can't work with a derived module called (say) "myCube"
> > without any need for developers to waste time changing the underlying
> > code.
>
> It seems to me that the main use of redefining modules is to extend
> functionality somehow in a library, so the existing built-ins can behave
> consistently in the context of the library with other functionality.  
>
> The argument that the name "cube" is sacrosanct appears every day on this
> forum:  many people seem to think that the burden of learning a new command
> is quite overwhelming.  
>
>
> > I get the impression that there is a large number of libraries with,
> > perhaps, a lot of close-but-not-perfect duplication amongst them. If that
> > is
> > the problem then it should be fixed by some process of getting library
> > developers to work to a common standard, not by changing the core code.
>
> I would say that the situation is not so clear.  There do not appears to be
> very many good libraries, well documented, that you can easily find.   I'm
> not aware of a lot of good libraries that duplicate each other
> substantially---maybe just BOSL with parts of dotSCAD.   But in my efforts
> to hunt for libraries I saw a lot of functionality duplicated many times by
> different people, maybe not put out as a library, but code that does the
> same class of basic things, written by each individual to support other
> purposes, because sharing libraries seems to be, for some reason, a very
> difficult thing.  And if you write a library for your own use there's little
> reason to bother documenting it.  
>
> The lack of a really clear mechanism for distributing libraries has been one
> problem.  It's pretty hard to find the various libraries that are scattered
> on Thingiverse.  The general hostility of people on the forum to the use of
> libraries is another factor that I think has discouraged the development of
> a functional approach to libraries.  
>
>
>
>
> --
> Sent from: http://forum.openscad.org/
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Extending OpenSCAD from assembler to C or Perlish language and adding standard library

nophead
It would be better if Relativity could just add new features to `cube`, `sphere` and so on without requiring you to rewrite all of your code.

But you can redefine cube and sphere. They hide the originals but there really isn't any need to call the originals as they don't do anything special. You would have a problem redefining polygon, and polyhedron though I think.

On Wed, 18 Sep 2019 at 00:46, Doug Moen <[hidden email]> wrote:
My original reason for wanting this feature is the Relativity library.
https://github.com/davidson16807/relativity.scad

Relativity extends the standard primitives `cube`, `sphere`, etc, with upward compatible new features: a system of property inheritance inspired by CSS.

But, because of the way OpenSCAD works, Relativity needs to invent new names for all of the primitives. So, `cube` becomes `box`, `cylinder` becomes `rod`, and so on.

So if you want to use Relativity in an existing project, you need to rewrite your code to replace `cube` with `box` and so on.

It would be better if Relativity could just add new features to `cube`, `sphere` and so on without requiring you to rewrite all of your code.

This would not be a problem in any modern programming language, because all modern languages support name spaces.

The underlying goal of many of the suggestions in my email was to provide tools for library writers, so that libraries can work better. And so that libraries can do things that currently require a change to the C++ core. We need a better library ecosystem. If you don't use libraries, then many of my suggested language changes won't help you.

Doug Moen.

On Tue, Sep 17, 2019, at 7:11 PM, adrianv wrote:
> Robin2 wrote
> > Sorry, but I just can't see the point. What is so sacrosanct about the
> > name
> > "cube" that someone can't work with a derived module called (say) "myCube"
> > without any need for developers to waste time changing the underlying
> > code.
>
> It seems to me that the main use of redefining modules is to extend
> functionality somehow in a library, so the existing built-ins can behave
> consistently in the context of the library with other functionality. 
>
> The argument that the name "cube" is sacrosanct appears every day on this
> forum:  many people seem to think that the burden of learning a new command
> is quite overwhelming. 
>
>
> > I get the impression that there is a large number of libraries with,
> > perhaps, a lot of close-but-not-perfect duplication amongst them. If that
> > is
> > the problem then it should be fixed by some process of getting library
> > developers to work to a common standard, not by changing the core code.
>
> I would say that the situation is not so clear.  There do not appears to be
> very many good libraries, well documented, that you can easily find.   I'm
> not aware of a lot of good libraries that duplicate each other
> substantially---maybe just BOSL with parts of dotSCAD.   But in my efforts
> to hunt for libraries I saw a lot of functionality duplicated many times by
> different people, maybe not put out as a library, but code that does the
> same class of basic things, written by each individual to support other
> purposes, because sharing libraries seems to be, for some reason, a very
> difficult thing.  And if you write a library for your own use there's little
> reason to bother documenting it.   
>
> The lack of a really clear mechanism for distributing libraries has been one
> problem.  It's pretty hard to find the various libraries that are scattered
> on Thingiverse.  The general hostility of people on the forum to the use of
> libraries is another factor that I think has discouraged the development of
> a functional approach to libraries. 
>
>
>
>
> --
> Sent from: http://forum.openscad.org/
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Extending OpenSCAD from assembler to C or Perlish language and adding standard library

lostapathy
In reply to this post by nophead

On 9/17/19 6:28 PM, nop head wrote:
> many people seem to think that the burden of learning a new command is quite overwhelming.  

OpenScad is a tiny language and can be learned in its entirety in about a day, which I did many years ago. Libraries are much larger things to learn, and if I can write everything I use myself, why would I spend time learning somebody else's library?

I think the reason why they don't gain the same traction as conventional programming languages is most things are very easy to do in OpenSCAD with a few lines of code, whereas most libraries for other languages are a lot bigger and more complicated.

I wish we would quit repeating this like it's the whole truth.  This type of talk derails discussions that might lead to a decent library ecosystem.

Yes, it's "easy" to do many things quickly.  It's also very easy to end up with a "library" that's not actually very reusable, or hopelessly slow, or fails to handle edge cases, or fails to provide reasonable validation/assertions (making it easy to have problems using it). 

Making good, reusable, documented libraries is *hard*.  Both because of the nature of the work, but also because there are *very few* great examples of libraries for OpenSCAD.  There's little work to borrow from, so users tend to fall into the same beginner traps and either call it "good enough for today's project" or give up on OpenSCAD entirely. 

I have talked to many people off-list who were discouraged by this "OpenSCAD doesn't need libraries" talk and just gave up rather than contributing.  I really wish the negativity around libraries and package managers would stop.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Extending OpenSCAD from assembler to C or Perlish language and adding standard library

adrianv
In reply to this post by nophead
nophead wrote
>> many people seem to think that the burden of learning a new command is
> quite overwhelming.
>
> OpenScad is a tiny language and can be learned in its entirety in about a
> day, which I did many years ago. Libraries are much larger things to
> learn,
> and if I can write everything I use myself, why would I spend time
> learning
> somebody else's library?

I did not find it so easy to learn OpenSCAD as apparently you did.  Dealing
with the immutability of variables, and the need to use tail recursions
instead of loops---these things are not obvious.  And without any code
examples (because there are no libraries to read) one is left rather adrift
in trying to figure this stuff out.  

Did you not just recently post that you redesigned your code using a
different design philosophy of making everything from extruded 2d shapes and
got it to render much faster?  (Assuming I remembered that correctly) that
suggests to me that you are *still* learning how to use OpenSCAD.  Note that
knowing how to use the language is not just knowing its commands, but
understanding fully, deeply, how they interact, and the advantages and
disadvantages of different approaches for modeling the same thing.  I'm kind
of skeptical that there are many people who really understand the ins and
outs of polyhedron() within the first day of using OpenSCAD.  Indeed, there
may not be many such people at all.  

The question "If I can write everything I use myself, why would Is spend
time learning somebody else's library?" is really bizarre to me.  I can, in
principle, write everything I do on the computer myself in assembly
language.  But would I want to do that?  Heck no!   It would take a *lot*
longer to do that than to learn the libraries.  And at least for me, the
effort of learning a library, or the 10 seconds it takes to check the
library manual to remember a parameter name, is much less than the effort
required to write the thing again from scratch.  And for me it tends to
produce code that is more maintainable.  
Indeed, the question I would pose in general is: "If there is a library that
does it, why would I spend the time writing it myself??"


> I think the reason why they don't gain the same traction as conventional
> programming languages is most things are very easy to do in OpenSCAD with
> a
> few lines of code, whereas most libraries for other languages are a lot
> bigger and more complicated.

I think the reason they don't gain the same traction as conventional
programming languages is that a vocal population here on the forum thinks
they are unnecessary because the things *those*people*want*to*do* are easy.
And for some reason some of these people *vocally*oppose* libraries instead
of just ignoring them.  That's what I find puzzling.  If someone is happy
with base OpenSCAD that person can be happy and go model something----and
*ignore* any libraries that are written.  Why are libraries so offensive to
people who aren't going to use them?  
 
If you want to make just rectangular objects with sharp corners, then things
are in fact pretty easy.  But if you want to do things that are curved, with
rounded edges, not so much.   My first OpenSCAD design is 108 lines and my
second one is the same length.  My third one design is 357 lines of
OpenSCAD, and it wasan't "very easy" or what I would consider "a few lines
of code".  The modeling process was pretty painful and there were lots of
steps that were trial-and-error based, which I hate.  It also takes about 20
minutes to render, which was pretty annoying during design.   The desire to
make this sort of model easier is what lead me to search for libraries.    





--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Extending OpenSCAD from assembler to C or Perlish language and adding standard library

lostapathy
On 9/17/19 7:21 PM, adrianv wrote:
nophead wrote

I think the reason why they don't gain the same traction as conventional
programming languages is most things are very easy to do in OpenSCAD with
a
few lines of code, whereas most libraries for other languages are a lot
bigger and more complicated.
I think the reason they don't gain the same traction as conventional
programming languages is that a vocal population here on the forum thinks
they are unnecessary because the things *those*people*want*to*do* are easy. 
And for some reason some of these people *vocally*oppose* libraries instead
of just ignoring them.  That's what I find puzzling.  If someone is happy
with base OpenSCAD that person can be happy and go model something----and
*ignore* any libraries that are written.  Why are libraries so offensive to
people who aren't going to use them?  


This times 1000!  Nobody is going to make you use other people's libraries, but there's no reason to discourage everyone else from writing them.  Please quit doing so!

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Extending OpenSCAD from assembler to C or Perlish language and adding standard library

MichaelAtOz
Administrator
In reply to this post by adrianv
adrianv wrote
> The lack of a really clear mechanism for distributing libraries has been
> one
> problem.  It's pretty hard to find the various libraries that are
> scattered
> on Thingiverse.  

It is also that the language needs further mechanisms to facilitate
libraries.
There is a basic mechanism, the libraries directory of OpenSCAD releases,
however as MCAD has shown it's development is hindered by (as Doug has
written just now) lack of " tools for library writers, so that libraries can
work better".
Then there can be a concept of 'std' libraries and external libraries. Once
there is better library support a 'std' library will be maintainable and
'best' practice can be developed. [I think tp's 'Functions literals / higher
order functions' will prove to be very helpful, add namespaces and probably
few other smaller pieces to support versioning, and it becomes workable]

> The general hostility of people on the forum to the use of
> libraries is another factor that I think has discouraged the development
> of
> a functional approach to libraries.  

There are, at least, two types of people here, those who subscribe to the
concept of standard libraries, and those who prefer to roll their own.
Personally I'm in both camps. Both types have explained their reasoning
here.
I have not detected hostility, and I don't think views of roll their own are
trying to discourage developments. Or that evangelicals should expect others
to see the light.

This type of discussion come up every year or two then fades away.

Instead of discussing libraries, I think the focus should be on "tools for
library writers" AND maintainers.
Then in conjunction developing 'best' practice guidelines on the criteria
code should have to be considered for formal inclusion in both a core
standard library [distributed in a release], or a 'recognised' external
library [that gets promoted on OpenSCAD web site, support with issues etc].

That's at least 3 phases and won't happen overnight.
I think namespaces would be a next logical step.

[I see there is now a bunch of replies I have yet to read, so obviously not
covered above]



-----
Admin - email* me if you need anything, or if I've done something stupid...

* click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.

The TPP is no simple “trade agreement.”   Fight it! http://www.ourfairdeal.org/   time is running out!
--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Admin - email* me if you need anything, or if I've done something stupid...
* click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work.
Obviously inclusion of works of previous authors is not included in the above.
123456